/*
 * ItemResource.cpp
 *
 *  Created on: 2013. 9. 11.
 *      Author: jjaehuny
 */

#include "../Enum.h"
#include "../User.h"
#include "../NUtil/Utils.h"
#include "Static.h"

#include "../xldata/item_class1.h"
#include "../xldata/item_class2.h"
#include "../xldata/item_class3.h"
#include "../xldata/item_class4.h"
#include "../xldata/item_class5.h"
#include "../xldata/item_class6.h"
#include "../xldata/item_common.h"
#include "../xldata/item_routing.h"
#include "../xldata/item_socket.h"
#include "../xldata/setitem.h"

#include <sys/types.h>
#include <unistd.h>

namespace ProjectZ { namespace NResource {

ItemResource::ItemResource() : _clsItemResourceTreeVector(static_cast<int>(CLASS_ALL_ITEM_TABLE_MAX + 1))
{
	emptyString = "";
}

ItemResource::~ItemResource() {

	std::for_each(_clsItemResourceTreeVector.begin(), _clsItemResourceTreeVector.end(), [](ITEMRESOURCETREE & tree) {
		std::for_each(tree.begin(), tree.end(), [](ITEMRESOURCETREE::value_type & pair) {
			delete pair.second;
		} );
	} );
}

void
ItemResource::Clear()
{
	std::for_each(_clsItemResourceTreeVector.begin(), _clsItemResourceTreeVector.end(), [](ITEMRESOURCETREE & tree) {
		std::for_each(tree.begin(), tree.end(), [](ITEMRESOURCETREE::value_type & pair) {
			delete pair.second;
		} );
	} );
	_clsItemResourceTreeVector.clear();
}

bool
ItemResource::LoadResource()
{
	::Database::Command::Auto clsAuto(::Database::GETCOMMANDPOOL());
	clsAuto->SetQueryType(::Database::Command::SELECT);
	clsAuto->MakeQuery("SELECT * FROM resource_item");

	if (false == ::Database::GETSESSION()->SyncExecute(1, clsAuto))
		return false;

	if( clsAuto->GetErrorIdx() != 0 )
		return false;

	if (0 == clsAuto->ResultRowCount())
		return false;

	Clear();

	while( clsAuto->Next() )
	{
		Flyweight * pFly = new Flyweight;

		::Toolkit::Str<3> NATIONAL_CODE;
//		int TID = 0;
		::Toolkit::Str<50> CLASSITEMTABLETYPE;
//		int ICON = 0;
		int DLC_TYPE = 0;
		::Toolkit::Str<50> USING;
		::Toolkit::Str<50> DESTROY;
		::Toolkit::Str<50> SALE;
		::Toolkit::Str<50> ITEM_EXCHANGE;
		::Toolkit::Str<50> STACK;
		::Toolkit::Str<50> BAGTYPE;
		::Toolkit::Str<50> SUBTYPE;
		::Toolkit::Str<50> CHARCLASSTYPE;
//		int PRICE = 0;
//		int DURABILITY = 0;
//		int LIMIT_LEVEL = 0;
		::Toolkit::Str<50> EFFECT;
//		int EFF_VALUE = 0;
		::Toolkit::Str<50> EFF_POS;

		clsAuto->GetRecord() >> NATIONAL_CODE >> pFly->_TID >> pFly->_CLASSITEMTABLETYPE
				>> pFly->_ICON >> pFly->_NAME_KOR >> pFly->_NAME_ENG >> pFly->_NAME_JPN >> DLC_TYPE
				>> pFly->_USING >> pFly->_DESTROY >> pFly->_SALE >> pFly->_ITEM_EXCHANGE >> pFly->_STACK
				>> pFly->_BAGTYPE >> pFly->_SUBTYPE >> pFly->_CHARCLASSTYPE >>pFly->_PRICE
				>> pFly->_DURABILITY >> pFly->_LIMIT_LEVEL >> pFly->_EFFECT
				>> pFly->_EFF_VALUE >> pFly->_EFF_POS;

		if (0 != Config::Instance().GetResourceDatabase()._strNational.compare(NATIONAL_CODE.c_str()))
		{
			DEBUGLOG("%s:%d NATIONAL_CODE ERROR!!! Config National Code [%s] , Resource National Code [%s]",
					__FILE__, __LINE__,
					Config::Instance().GetResourceDatabase()._strNational.c_str(),
					NATIONAL_CODE.c_str());
			return false;
		}

#if 0
		//DEBUGLOG("-------------------------------------------");
		//DEBUGLOG("TID : %d", TID);
		pFly->_TID = TID;


		int value = 0;
		bool bRet = false;
//		bool bRet = Static::Instance().GetStringMatch()->GetValue(CLASSITEMTABLETYPE.c_str(), value);
//		if (bRet == false)
//		{
//			DEBUGLOG("ITEM RESOURCE CLASSITEMTABLETYPE : %s VALUE : %d", CLASSITEMTABLETYPE.c_str(), value);
//			return false;
//		}
//		pFly->_CLASSITEMTABLETYPE = value;

		//DEBUGLOG("ICON : %d", ICON);
		pFly->_ICON = ICON;
		//DEBUGLOG("TID : %s", NAME_KOR.c_str());
		//DEBUGLOG("TID : %s", NAME_ENG.c_str());
		//DEBUGLOG("TID : %s", NAME_JPN.c_str());

		value = 0;
		bRet = Static::Instance().GetStringMatch()->GetValue(DLC_TYPE.c_str(), value);
		if (bRet == false)
		{
			DEBUGLOG("ITEM RESOURCE DLC_TYPE : %s VALUE : %d", DLC_TYPE.c_str(), value);
			return false;
		}

		value = 0;
		bRet = Static::Instance().GetStringMatch()->GetValue(USING.c_str(), value);
		if (bRet == false)
		{
			DEBUGLOG("ITEM RESOURCE USING : %s VALUE : %d", USING.c_str(), value);
			return false;
		}

		pFly->_USING = value;

		value = 0;
		bRet = Static::Instance().GetStringMatch()->GetValue(DESTROY.c_str(), value);
		if (bRet == false)
		{
			DEBUGLOG("ITEM RESOURCE DESTROY : %s VALUE : %d", DESTROY.c_str(), value);
			return false;
		}

		pFly->_DESTROY = value;

		value = 0;
		bRet = Static::Instance().GetStringMatch()->GetValue(SALE.c_str(), value);
		if (bRet == false)
		{
			DEBUGLOG("ITEM RESOURCE SALE : %s VALUE : %d", SALE.c_str(), value);
			return false;
		}
		pFly->_SALE = value;

		value = 0;
		bRet = Static::Instance().GetStringMatch()->GetValue(ITEM_EXCHANGE.c_str(), value);
		if (bRet == false)
		{
			DEBUGLOG("ITEM RESOURCE ITEM_EXCHANGE : %s VALUE : %d", ITEM_EXCHANGE.c_str(), value);
			return false;
		}
		pFly->_ITEM_EXCHANGE = value;

		value = 0;
		bRet = Static::Instance().GetStringMatch()->GetValue(STACK.c_str(), value);
		if (bRet == false)
		{
			DEBUGLOG("ITEM RESOURCE STACK : %s VALUE : %d", STACK.c_str(), value);
			return false;
		}
		pFly->_STACK = value;

		value = 0;
		bRet = Static::Instance().GetStringMatch()->GetValue(BAGTYPE.c_str(), value);
		if (bRet == false)
		{
			DEBUGLOG("ITEM RESOURCE BAGTYPE : %s VALUE : %d", BAGTYPE.c_str(), value);
			return false;
		}
		pFly->_BAGTYPE = value;

		value = 0;
		bRet = Static::Instance().GetStringMatch()->GetValue(SUBTYPE.c_str(), value);
		if (bRet == false)
		{
			DEBUGLOG("ITEM RESOURCE SUBTYPE : %s VALUE : %d", SUBTYPE.c_str(), value);
			return false;
		}
		pFly->_SUBTYPE = value;

		value = 0;
		bRet = Static::Instance().GetStringMatch()->GetValue(CHARCLASSTYPE.c_str(), value);
		if (bRet == false)
		{
			DEBUGLOG("ITEM RESOURCE CHARCLASSTYPE : %s VALUE : %d", CHARCLASSTYPE.c_str(), value);
			return false;
		}
		pFly->_CHARCLASSTYPE = value;

		//DEBUGLOG("PRICE : %d", PRICE);
		pFly->_PRICE = PRICE;
		//DEBUGLOG("DURABILITY : %d", DURABILITY);
		pFly->_DURABILITY = DURABILITY;
		//DEBUGLOG("LIMIT_LEVEL : %d", LIMIT_LEVEL);
		pFly->_LIMIT_LEVEL = LIMIT_LEVEL;

		value = 0;
		bRet = Static::Instance().GetStringMatch()->GetValue(EFFECT.c_str(), value);

		if (bRet == false)
		{
			DEBUGLOG("ITEM RESOURCE EFFECT : %s VALUE : %d", EFFECT.c_str(), value);
			return false;
		}
		pFly->_EFFECT = value;

		//DEBUGLOG("EFF_VALUE : %d", EFF_VALUE);
		pFly->_EFF_VALUE = EFF_VALUE;

		value = 0;
		bRet = Static::Instance().GetStringMatch()->GetValue(EFF_POS.c_str(), value);
		if (bRet == false)
		{
			DEBUGLOG("ITEM RESOURCE EFF_POS : %s VALUE : %d", EFF_POS.c_str(), value);
			return false;
		}
		pFly->_EFF_POS = value;
#endif

		ITEMRESOURCETREE & clsItemResourceTree = _clsItemResourceTreeVector[pFly->_CLASSITEMTABLETYPE];
		clsItemResourceTree[ItemResource::Key(pFly->_TID, pFly->_CHARCLASSTYPE)] = pFly;
	}

	return true;

}


bool
ItemResource::SetItemDataFromResource(User * pUser, NLogic::Item::Data & clsData)
{
	NResource::BalanceData * pBalance = NResource::Static::InstancePtr()->GetBalance()->GetBalancePtr(pUser);
	if (NULL == pBalance)
	{
		DEBUGLOG("%s : pBalance is NULL!", __FUNCTION__);
		return false;
	}

	Flyweight * pFly = getFly(clsData.sub_type, clsData.tid, clsData.class_type);
	if (NULL == pFly)
	{
		DEBUGLOG("%s : pFly is NULL! sub_type : %d, tid : %d, class_type : %d", __FUNCTION__,
				clsData.sub_type, clsData.tid, clsData.class_type);
		return false;
	}

//	if (clsData.sub_type >= CLASS_ITEM_TABLE_MAX)
//		clsData.class_type = -1;
//
//	ItemResource::Key clsKey(clsData.tid, clsData.class_type, clsData.sub_type);
//	auto itr = _clsFlyTree.find(clsKey);
//	if (itr == _clsFlyTree.end())
//	{
//		DEBUGLOG("%s : NULL == ItemFly! tid : %d, class_type : %d, sub_type : %d", __FUNCTION__);
//		//return;
//	}
//	ItemResource::Flyweight * ItemFly = itr->second;

	clsData.bag_type = this->GetItemBagType(clsData);
	clsData.level	 = this->GetItemLevel(clsData);
	clsData.cur_duration 	= this->GetItemDurability(clsData);
	clsData.max_duration	= this->GetItemDurability(clsData);
	clsData.max_enhance_step = this->GetItemMaxRefine(pBalance, clsData);
	clsData.iconidx	= this->GetIconIndex(clsData);

	// 아이템 사용 가능 여부
	clsData.item_type = this->GetItemUsing(clsData);

	// 아이템 귀속 여부
	clsData.buy_use = this->GetItemBelong(pBalance, clsData);

	// 아이템 강화석 오픈 슬롯 수
	clsData.open_upgrade_stone_slot = this->GetItemOpenSlotCount(clsData);

	// 세트 아이템 여부 결정
	clsData.set_type = this->GetItemSettedType(pBalance, clsData);

	// 아이템 미식별 여부
	clsData.non_identity = this->IsItemIdentify(pBalance, clsData);

	// 아이템 추가 효과 세팅
	// 아이템에 추가 효과를 부여하기 위해서는 기본적인 아이템의 정보가 세팅 되어 있어야 한다. (아이템등급, TID, SheetType, 장착 클래스, 기본 효과)
	this->SetAdditionalEffect(clsData);

	return true;
}

bool
ItemResource::SetItemFromXLS(User * pUser, NLogic::Item::Data & clsData, int sheet, int tid, int quantity)
{
	clsData.class_type 	= GetClassType(pUser, tid, sheet);

	clsData.tid			= tid;						// 아이템 TID
	clsData.sub_type		= sheet;					// Sheet type
	clsData.quantity		= quantity;					// 아이템 수량

	clsData.bag_type 		= GetItemBagType(clsData);			// 가방 타입
	clsData.cur_duration = GetItemDurability(clsData);		// 현재 내구도
	clsData.max_duration	= clsData.cur_duration;	// 최대 내구도
	clsData.level			= GetItemLevel(clsData);			// 아이템 레벨
	//clsData.iconidx	= 	this->GetIconIndex(clsData);

	if (1 != NResource::Static::Instance().GetItemResource()->getItemStackType(clsData))
	{
		if (quantity >= 2)
			return false;
	}

	// 아바타 구매인 경우 능력치 설정
	if (sheet == CLASS_ITEM_TABLE_AVATAR)
	{

		AvatarAblityResource::Flyweight * pFly =
				Static::InstancePtr()->GetAvatarAblityResource()->GetFly(pUser->GetCharacterInfo().level);
		if (NULL == pFly)
		{
			DEBUGLOG("SetItemFromXLS : pFly is NULL!!");
			return false;
		}

		BalanceData * pBalance = Static::InstancePtr()->GetBalance()->GetBalancePtr(pUser);
		if (NULL == pBalance)
		{
			DEBUGLOG("SetItemFromXLS : pBalance is NULL!!");
			return false;
		}

		int addVal = 0;

		switch (tid)
		{
		case 0: addVal = pBalance->GetValue(EM_AVATAR1_ABILITY_CONST); break;
		case 1: addVal = pBalance->GetValue(EM_AVATAR2_ABILITY_CONST); break;
		case 2: addVal = pBalance->GetValue(EM_AVATAR3_ABILITY_CONST); break;
		case 3: addVal = pBalance->GetValue(EM_AVATAR4_ABILITY_CONST); break;
		case 4: addVal = pBalance->GetValue(EM_AVATAR5_ABILITY_CONST); break;
		case 5: addVal = pBalance->GetValue(EM_AVATAR6_ABILITY_CONST); break;
		case 6: addVal = pBalance->GetValue(EM_AVATAR7_ABILITY_CONST); break;
		}

		int minVal = pFly->_ADD_MIN + addVal;
		int maxVal = pFly->_ADD_MAX + addVal;

		clsData.eff_type[0]	= ITEM_EFFECT_ATT;	// 공격력
		clsData.eff_pos[0]	= 1;	// 0:+, 1:%
		clsData.eff_value[0] = NUtil::GetRandBetween(minVal, maxVal);
	}
	else
	{
		this->setItemEffect(clsData);
	}

	return true;
}

const char *
ItemResource::GetItemName(NLogic::Item::Data & clsData)
{
	Flyweight * pFly = getFly(clsData.sub_type, clsData.tid, clsData.class_type);
	if (NULL == pFly)
	{
		DEBUGLOG("%s : pFly is NULL! sub_type : %d, tid : %d, class_type : %d", __FUNCTION__,
				clsData.sub_type, clsData.tid, clsData.class_type);
		return emptyString.c_str();
	}
	return pFly->_NAME_KOR.c_str();
}

int ItemResource::GetIconIndex(NLogic::Item::Data & clsData)
{
	Flyweight * pFly = getFly(clsData.sub_type, clsData.tid, clsData.class_type);
	if (NULL == pFly)
	{
		DEBUGLOG("%s : pFly is NULL! sub_type : %d, tid : %d, class_type : %d", __FUNCTION__,
				clsData.sub_type, clsData.tid, clsData.class_type);
		return -1;
	}
	return pFly->_ICON;

//	using namespace NXLData;
//
//	// for non-class type items
//	switch (clsData.sub_type)
//	{
//	case CLASS_ITEM_TABLE_NECKLACE:
//		return stItem_Common_Common_Necklace[clsData.tid].ICON;
//	case CLASS_ITEM_TABLE_CLOAK:
//		return stItem_Common_Commonitem_Cloak[clsData.tid].ICON;
//	case CLASS_ITEM_TABLE_RING:
//		return stItem_Common_Commonitem_Ring[clsData.tid].ICON;
//	case CLASS_ITEM_TABLE_CHARM:
//		return stItem_Common_Commonitem_Charm[clsData.tid].ICON;
//	case CLASS_ITEM_TABLE_TITLE:
//		return stItem_Common_Commonitem_Title[clsData.tid].ICON;
//	case CLASS_ITEM_TABLE_CHARGE:
//		return stItem_Common_Commonitem_Charge[clsData.tid].ICON;
//	case CLASS_ITEM_TABLE_QUEST:
//		return stItem_Common_Commonitem_Quest[clsData.tid].ICON;
//	case CLASS_ITEM_TABLE_ETC:
//		return stItem_Common_Commonitem_Etc[clsData.tid].ICON;
//	case CLASS_ITEM_TABLE_VEHICLE:
//		return stItem_Common_Commonitem_Vehicle[clsData.tid].ICON;
//	case CLASS_ITEM_TABLE_BATTLE_PET :
//		return stItem_Common_Commonitem_Pet[clsData.tid].ICON;
//	}
//
//
//	if (clsData.class_type == CLASS_TYPE_SLASHER)
//	{
//		switch (clsData.sub_type)
//		{
//		case CLASS_ITEM_TABLE_WEAPONE:
//			return stItem_Class1_Weapon01[clsData.tid].ICON;
//		case CLASS_ITEM_TABLE_HELMET:
//			return stItem_Class1_Helmet01[clsData.tid].ICON;
//		case CLASS_ITEM_TABLE_ARMOR:
//			return stItem_Class1_Armor01[clsData.tid].ICON;
//		case CLASS_ITEM_TABLE_GLOVES:
//			return stItem_Class1_Gloves01[clsData.tid].ICON;
//		case CLASS_ITEM_TABLE_SHOES:
//			return stItem_Class1_Shoes01[clsData.tid].ICON;
//		case CLASS_ITEM_TABLE_AVATAR :
//			return stItem_Class1_Avatar01[clsData.tid].ICON;
//		}
//	}
//	else if (clsData.class_type == CLASS_TYPE_RANGER)
//	{
//		switch (clsData.sub_type)
//		{
//		case CLASS_ITEM_TABLE_WEAPONE:
//			return stItem_Class2_Weapon02[clsData.tid].ICON;
//		case CLASS_ITEM_TABLE_HELMET:
//			return stItem_Class2_Helmet02[clsData.tid].ICON;
//		case CLASS_ITEM_TABLE_ARMOR:
//			return stItem_Class2_Armor02[clsData.tid].ICON;
//		case CLASS_ITEM_TABLE_GLOVES:
//			return stItem_Class2_Gloves02[clsData.tid].ICON;
//		case CLASS_ITEM_TABLE_SHOES:
//			return stItem_Class2_Shoes02[clsData.tid].ICON;
//		case CLASS_ITEM_TABLE_AVATAR :
//			return stItem_Class2_Avatar02[clsData.tid].ICON;
//		}
//	}
//	else if (clsData.class_type == CLASS_TYPE_FIGHTER)
//	{
//		switch (clsData.sub_type)
//		{
//		case CLASS_ITEM_TABLE_WEAPONE:
//			return stItem_Class3_Weapon03[clsData.tid].ICON;
//		case CLASS_ITEM_TABLE_HELMET:
//			return stItem_Class3_Helmet03[clsData.tid].ICON;
//		case CLASS_ITEM_TABLE_ARMOR:
//			return stItem_Class3_Armor03[clsData.tid].ICON;
//		case CLASS_ITEM_TABLE_GLOVES:
//			return stItem_Class3_Gloves03[clsData.tid].ICON;
//		case CLASS_ITEM_TABLE_SHOES:
//			return stItem_Class3_Shoes03[clsData.tid].ICON;
//		case CLASS_ITEM_TABLE_AVATAR :
//			return stItem_Class3_Avatar03[clsData.tid].ICON;
//		}
//	}
//	else if (clsData.class_type == CLASS_TYPE_MAGICIAN)
//	{
//		switch (clsData.sub_type)
//		{
//		case CLASS_ITEM_TABLE_WEAPONE:
//			return stItem_Class4_Weapon04[clsData.tid].ICON;
//		case CLASS_ITEM_TABLE_HELMET:
//			return stItem_Class4_Helmet04[clsData.tid].ICON;
//		case CLASS_ITEM_TABLE_ARMOR:
//			return stItem_Class4_Armor04[clsData.tid].ICON;
//		case CLASS_ITEM_TABLE_GLOVES:
//			return stItem_Class4_Gloves04[clsData.tid].ICON;
//		case CLASS_ITEM_TABLE_SHOES:
//			return stItem_Class4_Shoes04[clsData.tid].ICON;
//		case CLASS_ITEM_TABLE_AVATAR :
//			return stItem_Class4_Avatar04[clsData.tid].ICON;
//		}
//	}
//	else if (clsData.class_type == CLASS_TYPE_ASSASSIN)
//	{
//		switch (clsData.sub_type)
//		{
//		case CLASS_ITEM_TABLE_WEAPONE:
//			return stItem_Class5_Weapon05[clsData.tid].ICON;
//		case CLASS_ITEM_TABLE_HELMET:
//			return stItem_Class5_Helmet05[clsData.tid].ICON;
//		case CLASS_ITEM_TABLE_ARMOR:
//			return stItem_Class5_Armor05[clsData.tid].ICON;
//		case CLASS_ITEM_TABLE_GLOVES:
//			return stItem_Class5_Gloves05[clsData.tid].ICON;
//		case CLASS_ITEM_TABLE_SHOES:
//			return stItem_Class5_Shoes05[clsData.tid].ICON;
//		case CLASS_ITEM_TABLE_AVATAR :
//			return stItem_Class5_Avatar05[clsData.tid].ICON;
//		}
//	}

	return 0;
}

int
ItemResource::GetItemUsing(NLogic::Item::Data & clsData)
{
	Flyweight * pFly = getFly(clsData.sub_type, clsData.tid, clsData.class_type);
	if (NULL == pFly)
	{
		DEBUGLOG("%s : pFly is NULL! sub_type : %d, tid : %d, class_type : %d", __FUNCTION__,
				clsData.sub_type, clsData.tid, clsData.class_type);
		return -1;
	}
	return pFly->_USING;
//	using namespace NXLData;
//
//	// for non-class type items
//	switch (clsData.sub_type)
//	{
//	case CLASS_ITEM_TABLE_NECKLACE:
//		return stItem_Common_Common_Necklace[clsData.tid].USING;
//	case CLASS_ITEM_TABLE_CLOAK:
//		return stItem_Common_Commonitem_Cloak[clsData.tid].USING;
//	case CLASS_ITEM_TABLE_RING:
//		return stItem_Common_Commonitem_Ring[clsData.tid].USING;
//	case CLASS_ITEM_TABLE_CHARM:
//		return stItem_Common_Commonitem_Charm[clsData.tid].USING;
//	case CLASS_ITEM_TABLE_TITLE:
//		return stItem_Common_Commonitem_Title[clsData.tid].USING;
//	case CLASS_ITEM_TABLE_CHARGE:
//		return stItem_Common_Commonitem_Charge[clsData.tid].USING;
//	case CLASS_ITEM_TABLE_QUEST:
//		return stItem_Common_Commonitem_Quest[clsData.tid].USING;
//	case CLASS_ITEM_TABLE_ETC:
//		return stItem_Common_Commonitem_Etc[clsData.tid].USING;
//	case CLASS_ITEM_TABLE_VEHICLE:
//		return stItem_Common_Commonitem_Vehicle[clsData.tid].USING;
//	case CLASS_ITEM_TABLE_BATTLE_PET :
//		return stItem_Common_Commonitem_Pet[clsData.tid].USING;
//	}
//
//
//	if (clsData.class_type == CLASS_TYPE_SLASHER)
//	{
//		switch (clsData.sub_type)
//		{
//		case CLASS_ITEM_TABLE_WEAPONE:
//			return stItem_Class1_Weapon01[clsData.tid].USING;
//		case CLASS_ITEM_TABLE_HELMET:
//			return stItem_Class1_Helmet01[clsData.tid].USING;
//		case CLASS_ITEM_TABLE_ARMOR:
//			return stItem_Class1_Armor01[clsData.tid].USING;
//		case CLASS_ITEM_TABLE_GLOVES:
//			return stItem_Class1_Gloves01[clsData.tid].USING;
//		case CLASS_ITEM_TABLE_SHOES:
//			return stItem_Class1_Shoes01[clsData.tid].USING;
//		case CLASS_ITEM_TABLE_AVATAR :
//			return stItem_Class1_Avatar01[clsData.tid].USING;
//		}
//	}
//	else if (clsData.class_type == CLASS_TYPE_RANGER)
//	{
//		switch (clsData.sub_type)
//		{
//		case CLASS_ITEM_TABLE_WEAPONE:
//			return stItem_Class2_Weapon02[clsData.tid].USING;
//		case CLASS_ITEM_TABLE_HELMET:
//			return stItem_Class2_Helmet02[clsData.tid].USING;
//		case CLASS_ITEM_TABLE_ARMOR:
//			return stItem_Class2_Armor02[clsData.tid].USING;
//		case CLASS_ITEM_TABLE_GLOVES:
//			return stItem_Class2_Gloves02[clsData.tid].USING;
//		case CLASS_ITEM_TABLE_SHOES:
//			return stItem_Class2_Shoes02[clsData.tid].USING;
//		case CLASS_ITEM_TABLE_AVATAR :
//			return stItem_Class2_Avatar02[clsData.tid].USING;
//		}
//	}
//	else if (clsData.class_type == CLASS_TYPE_FIGHTER)
//	{
//		switch (clsData.sub_type)
//		{
//		case CLASS_ITEM_TABLE_WEAPONE:
//			return stItem_Class3_Weapon03[clsData.tid].USING;
//		case CLASS_ITEM_TABLE_HELMET:
//			return stItem_Class3_Helmet03[clsData.tid].USING;
//		case CLASS_ITEM_TABLE_ARMOR:
//			return stItem_Class3_Armor03[clsData.tid].USING;
//		case CLASS_ITEM_TABLE_GLOVES:
//			return stItem_Class3_Gloves03[clsData.tid].USING;
//		case CLASS_ITEM_TABLE_SHOES:
//			return stItem_Class3_Shoes03[clsData.tid].USING;
//		case CLASS_ITEM_TABLE_AVATAR :
//			return stItem_Class3_Avatar03[clsData.tid].USING;
//		}
//	}
//	else if (clsData.class_type == CLASS_TYPE_MAGICIAN)
//	{
//		switch (clsData.sub_type)
//		{
//		case CLASS_ITEM_TABLE_WEAPONE:
//			return stItem_Class4_Weapon04[clsData.tid].USING;
//		case CLASS_ITEM_TABLE_HELMET:
//			return stItem_Class4_Helmet04[clsData.tid].USING;
//		case CLASS_ITEM_TABLE_ARMOR:
//			return stItem_Class4_Armor04[clsData.tid].USING;
//		case CLASS_ITEM_TABLE_GLOVES:
//			return stItem_Class4_Gloves04[clsData.tid].USING;
//		case CLASS_ITEM_TABLE_SHOES:
//			return stItem_Class4_Shoes04[clsData.tid].USING;
//		case CLASS_ITEM_TABLE_AVATAR :
//			return stItem_Class4_Avatar04[clsData.tid].USING;
//		}
//	}
//	else if (clsData.class_type == CLASS_TYPE_ASSASSIN)
//	{
//		switch (clsData.sub_type)
//		{
//		case CLASS_ITEM_TABLE_WEAPONE:
//			return stItem_Class5_Weapon05[clsData.tid].USING;
//		case CLASS_ITEM_TABLE_HELMET:
//			return stItem_Class5_Helmet05[clsData.tid].USING;
//		case CLASS_ITEM_TABLE_ARMOR:
//			return stItem_Class5_Armor05[clsData.tid].USING;
//		case CLASS_ITEM_TABLE_GLOVES:
//			return stItem_Class5_Gloves05[clsData.tid].USING;
//		case CLASS_ITEM_TABLE_SHOES:
//			return stItem_Class5_Shoes05[clsData.tid].USING;
//		case CLASS_ITEM_TABLE_AVATAR :
//			return stItem_Class5_Avatar05[clsData.tid].USING;
//		}
//	}

	return 0;
}

int
ItemResource::GetItemSettedType(NResource::BalanceData * pBalance, NLogic::Item::Data & clsData)
{
	// NPC 상점에서 아이템을 구매하는 경우
	if (clsData.set_type == -99)
	{
		return -1;
	}

	// 세트아이템은 무기, 헬멧, 갑옷만 가능.
	if (clsData.sub_type != CLASS_ITEM_TABLE_WEAPONE && clsData.sub_type != CLASS_ITEM_TABLE_HELMET && clsData.sub_type != CLASS_ITEM_TABLE_ARMOR)
	{
		return -1;
	}

	int rate = rand() % 100;

	if (pBalance->GetValue(EM_SET_ITEM_DROP_PERCENT) < rate)
	{
		return -1;
	}

	NResource::SetItemResource * pSetItem = NResource::Static::Instance().GetSetItemResource();
	if (NULL == pSetItem)
	{
		return -1;
	}

	int setType = -1;
	auto iter = pSetItem->GetTree().begin();
	for (; iter != pSetItem->GetTree().end(); iter++)
	{
		int setItemTID = 0;

		switch (clsData.sub_type)
		{
		case CLASS_ITEM_TABLE_WEAPONE: setItemTID = iter->second->_SET_TID1; break;
		case CLASS_ITEM_TABLE_HELMET: setItemTID = iter->second->_SET_TID2; break;
		case CLASS_ITEM_TABLE_ARMOR: setItemTID = iter->second->_SET_TID3; break;
		}

		if (setItemTID == clsData.tid)
		{
			setType = iter->second->_SET_TYPE;
			break;
		}
	}

	return setType;




#if 0
	bool bSet = false;
	int setType = 0;
	int maxCount = NXLData::SETITEM_SETITEM_MAX;

	for ( ; setType < maxCount; setType++)
	{
		const NXLData::SETITEM_SETITEM * pSetItem = &NXLData::stSetitem_Setitem[setType];

		int setItemTID = 0;

		switch (clsData.sub_type)
		{
		case CLASS_ITEM_TABLE_WEAPONE: setItemTID = pSetItem->SET1_TID4; break;
		case CLASS_ITEM_TABLE_HELMET: setItemTID = pSetItem->SET2_TID5; break;
		case CLASS_ITEM_TABLE_ARMOR: setItemTID = pSetItem->SET3_TID6; break;
		}

		if (setItemTID == clsData.tid)
		{
			bSet = true;
			break;
		}
	}

	if (false == bSet)
	{
		setType = -1;
	}

	return setType;
#endif
}

bool
ItemResource::IsItemIdentify(NResource::BalanceData * pBalance, NLogic::Item::Data & clsData)
{
	/*
	 * 아이템 미식별 여부 결정
	 */

	// 아이템 뽑기 또는 던전 보상인 경우 무조건 식별아이템이 나와야 한다.
	if (clsData.non_identity == -99)
	{
		return false;
	}

	if (false == this->isEquip(clsData))
	{
		return false;
	}

	if (clsData.quality == ITEM_QUALITY_F)
	{
		return false;
	}

	int itemQuality = ITEM_QUALITY_SSS - clsData.quality;
	int identifyRate = pBalance->GetValue(EM_NONIDENTIFY_ITEM_RATE) - (itemQuality * pBalance->GetValue(EM_NONIDENTIFY_ITEM_RATE_CONST));

	identifyRate = (identifyRate > pBalance->GetValue(EM_NONIDENTIFY_ITEM_RATE_MIN)) ? identifyRate : pBalance->GetValue(EM_NONIDENTIFY_ITEM_RATE_MIN);

	int rate = rand() % 100;

	if (rate < identifyRate)
		return true;

	return false;
}

int
ItemResource::GetItemBelong(NResource::BalanceData * pBalance, NLogic::Item::Data & clsData)
{
	/*
	 * 아이템 귀속 여부 결정
	 */
	if (false == this->isEquip(clsData))
	{
		return 0;
	}

	int itemBelong = 0;

	int equipBelongRate = 0;	// 착귀 확률
	int acquireBelongRate = 0;	// 획귀 확률

	switch (clsData.quality)
	{
	case ITEM_QUALITY_F:
		equipBelongRate = pBalance->GetValue(EM_F_GRADE_EQUIP_BELONGING_RATE);
		acquireBelongRate = pBalance->GetValue(EM_F_GRADE_ACQUIRE_BELONGING_RATE);
		break;
	case ITEM_QUALITY_D:
		equipBelongRate = pBalance->GetValue(EM_D_GRADE_EQUIP_BELONGING_RATE);
		acquireBelongRate = pBalance->GetValue(EM_D_GRADE_ACQUIRE_BELONGING_RATE);
		break;
	case ITEM_QUALITY_C:
		equipBelongRate = pBalance->GetValue(EM_C_GRADE_EQUIP_BELONGING_RATE);
		acquireBelongRate = pBalance->GetValue(EM_C_GRADE_ACQUIRE_BELONGING_RATE);
		break;
	case ITEM_QUALITY_B:
		equipBelongRate = pBalance->GetValue(EM_B_GRADE_EQUIP_BELONGING_RATE);
		acquireBelongRate = pBalance->GetValue(EM_B_GRADE_ACQUIRE_BELONGING_RATE);
		break;
	case ITEM_QUALITY_A:
		equipBelongRate = pBalance->GetValue(EM_A_GRADE_EQUIP_BELONGING_RATE);
		acquireBelongRate = pBalance->GetValue(EM_A_GRADE_ACQUIRE_BELONGING_RATE);
		break;
	case ITEM_QUALITY_S:
		equipBelongRate = pBalance->GetValue(EM_S_GRADE_EQUIP_BELONGING_RATE);
		acquireBelongRate = pBalance->GetValue(EM_S_GRADE_ACQUIRE_BELONGING_RATE);
		break;
	case ITEM_QUALITY_SP:
	case ITEM_QUALITY_SS:
	case ITEM_QUALITY_SSP:
	case ITEM_QUALITY_SSS:
		equipBelongRate = pBalance->GetValue(EM_OVER_S_GRADE_EQUIP_BELONGING_RATE);
		acquireBelongRate = pBalance->GetValue(EM_OVER_S_GRADE_ACQUIRE_BELONGING_RATE);
		break;
	}


	int equipRate = rand() % 100;
	if (equipRate < equipBelongRate)
	{
		itemBelong = 1;
	}

	int acquireRate = rand() % 100;
	if (acquireRate < acquireBelongRate)
	{
		itemBelong = 3;
	}

	// 귀속 아이템인 경우 기본 능력치 상승
	int addPercent = 0;
	if (itemBelong == 1)
	{
		addPercent = pBalance->GetValue(EM_EQUIP_BELONGING_ADD_EFFECT_RATE);
	}
	else if (itemBelong == 3)
	{
		addPercent = pBalance->GetValue(EM_ACQUIRE_BELONGING_ADD_EFFECT_RATE);
	}

	if (addPercent > 0)
	{
		int effectVale = clsData.eff_value[0];
		clsData.eff_value[0] = effectVale + (effectVale * (addPercent / 100.0) );
	}

	return itemBelong;
}

int
ItemResource::GetItemMaxRefine(NResource::BalanceData * pBalance, NLogic::Item::Data & clsData)
{
	/*
	 * 아이템의 최재 제련 단계 결정
	 */
	if (false == this->isEquip(clsData))
		return 0;

	switch (clsData.quality)
	{
	case ITEM_QUALITY_D:	return pBalance->GetValue(EM_REFINE_ABLE_MAX_COUNT_D_GRADE);
	case ITEM_QUALITY_C:	return pBalance->GetValue(EM_REFINE_ABLE_MAX_COUNT_C_GRADE);
	case ITEM_QUALITY_B:	return pBalance->GetValue(EM_REFINE_ABLE_MAX_COUNT_B_GRADE);
	case ITEM_QUALITY_A:	return pBalance->GetValue(EM_REFINE_ABLE_MAX_COUNT_A_GRADE);
	case ITEM_QUALITY_S:	return pBalance->GetValue(EM_REFINE_ABLE_MAX_COUNT_S_GRADE);
	case ITEM_QUALITY_SP:	return pBalance->GetValue(EM_REFINE_ABLE_MAX_COUNT_SP_GRADE);
	case ITEM_QUALITY_SS:	return pBalance->GetValue(EM_REFINE_ABLE_MAX_COUNT_SS_GRADE);
	case ITEM_QUALITY_SSP:	return pBalance->GetValue(EM_REFINE_ABLE_MAX_COUNT_SSP_GRADE);
	case ITEM_QUALITY_SSS:	return pBalance->GetValue(EM_REFINE_ABLE_MAX_COUNT_SSS_GRADE);
	}

	return 0;
}

int
ItemResource::GetItemOpenSlotCount(NLogic::Item::Data & clsData)
{
	/*
	 * 아이템의 강화석 오픈 슬롯 수 결정
	 */
	if (false == this->isEquip(clsData))
	{
		return 0;
	}

	int maxSlotCount = NXLData::ITEM_SOCKET_ITEMSOCKET_MAX;

	const NXLData::ITEM_SOCKET_ITEMSOCKET * pItemSocket;
	std::vector< int > rateVector;
	rateVector.reserve(maxSlotCount);

	switch (clsData.quality)
	{
	case ITEM_QUALITY_F:
		for (int i = 0; i < maxSlotCount; i++)
		{
			pItemSocket = &NXLData::stItem_Socket_Itemsocket[i];
			rateVector.push_back(pItemSocket->F_RATE2);
		}
		break;
	case ITEM_QUALITY_D:
		for (int i = 0; i < maxSlotCount; i++)
		{
			pItemSocket = &NXLData::stItem_Socket_Itemsocket[i];
			rateVector.push_back(pItemSocket->D_RATE3);
		}
		break;
	case ITEM_QUALITY_C:
		for (int i = 0; i < maxSlotCount; i++)
		{
			pItemSocket = &NXLData::stItem_Socket_Itemsocket[i];
			rateVector.push_back(pItemSocket->C_RATE4);
		}
		break;
	case ITEM_QUALITY_B:
		for (int i = 0; i < maxSlotCount; i++)
		{
			pItemSocket = &NXLData::stItem_Socket_Itemsocket[i];
			rateVector.push_back(pItemSocket->B_RATE5);
		}
		break;
	case ITEM_QUALITY_A:
		for (int i = 0; i < maxSlotCount; i++)
		{
			pItemSocket = &NXLData::stItem_Socket_Itemsocket[i];
			rateVector.push_back(pItemSocket->A_RATE6);
		}
		break;
	case ITEM_QUALITY_S:
		for (int i = 0; i < maxSlotCount; i++)
		{
			pItemSocket = &NXLData::stItem_Socket_Itemsocket[i];
			rateVector.push_back(pItemSocket->S_RATE7);
		}
		break;
	case ITEM_QUALITY_SP:
		for (int i = 0; i < maxSlotCount; i++)
		{
			pItemSocket = &NXLData::stItem_Socket_Itemsocket[i];
			rateVector.push_back(pItemSocket->SP_RATE8);
		}
		break;
	case ITEM_QUALITY_SS:
		for (int i = 0; i < maxSlotCount; i++)
		{
			pItemSocket = &NXLData::stItem_Socket_Itemsocket[i];
			rateVector.push_back(pItemSocket->SS_RATE9);
		}
		break;
	case ITEM_QUALITY_SSP:
		for (int i = 0; i < maxSlotCount; i++)
		{
			pItemSocket = &NXLData::stItem_Socket_Itemsocket[i];
			rateVector.push_back(pItemSocket->SSP_RATE10);
		}
		break;
	case ITEM_QUALITY_SSS:
		for (int i = 0; i < maxSlotCount; i++)
		{
			pItemSocket = &NXLData::stItem_Socket_Itemsocket[i];
			rateVector.push_back(pItemSocket->SSS_RATE11);
		}
		break;
	}

	int accRate = 0;
	int openSlot = 1;
	int openSlotRate = rand() % 100;

	for ( ; openSlot <= maxSlotCount; openSlot++)
	{
		accRate += rateVector[openSlot - 1];

		if (openSlotRate < accRate)
		{
			break;
		}
	}

	// 누적 확률이 0이하인 경우 오픈 슬롯 없음. (F등급 아이템)
	if (accRate <= 0)
	{
		openSlot = 0;
	}

	return openSlot;
}

bool
ItemResource::isEquip(const NLogic::Item::Data & clsData)
{
	switch (clsData.sub_type)
	{
	case CLASS_ITEM_TABLE_WEAPONE:
	case CLASS_ITEM_TABLE_HELMET:
	case CLASS_ITEM_TABLE_ARMOR:
	case CLASS_ITEM_TABLE_GLOVES:
	case CLASS_ITEM_TABLE_SHOES:
	case CLASS_ITEM_TABLE_NECKLACE:
	case CLASS_ITEM_TABLE_CLOAK:
	case CLASS_ITEM_TABLE_RING:
	case CLASS_ITEM_TABLE_CHARM:
		return true;
	default:
		return false;
	}
}

bool
ItemResource::isUpstone(const NLogic::Item::Data & clsData)
{
	if (clsData.sub_type == CLASS_ITEM_TABLE_ETC && clsData.tid == UPSTONE_TID)
		return true;

	return false;
}

bool
ItemResource::isFairy(const NLogic::Item::Data & clsData)
{
	if (clsData.bag_type == BAG_TYPE_FAIRY)
		return true;

	return false;
}

bool
ItemResource::isBattlePet(const NLogic::Item::Data & clsData)
{
	if (clsData.bag_type == BAG_TYPE_BATTLE_PET)
		return true;

	return false;
}

bool
ItemResource::isAccessary(const NLogic::Item::Data & clsData)
{
	switch (clsData.sub_type)
	{
	case CLASS_ITEM_TABLE_NECKLACE:
	case CLASS_ITEM_TABLE_CLOAK:
	case CLASS_ITEM_TABLE_RING:
	case CLASS_ITEM_TABLE_CHARM:
		return true;
	default:
		return false;
	}
}

void
ItemResource::SetAdditionalEffect(NLogic::Item::Data & clsData, bool bFairySacrifice)
{
	/*
	 * 아이템 추가 효과 결정
	 * 1번 슬롯 : 무기 또는 장신구 추가 효과
	 * 2번 슬롯 : 장신구 추가 효과
	 */
	// 장비가 아니면 추가 효과 없음.
	if (false == this->isEquip(clsData) && false == this->isUpstone(clsData))
	{
		return;
	}

	// D등급 이하면 추가 효과 없음.
	if (clsData.quality < ITEM_QUALITY_D)
	{
		return;
	}

	// 칭호 : 효과 고정
	if (clsData.sub_type == CLASS_ITEM_TABLE_TITLE)
	{
		return;
	}

	// 기본 효과 성능 향상.
	if (true == isEquip(clsData) && false == bFairySacrifice)
	{
		int upBasicPercent = this->getItemRoutingValue(clsData, 0);

		if (upBasicPercent < 0)
			return;
#if 0
		const NXLData::ITEM_ROUTING_ITEMROUTINGVALUE * pRoutingValue = &NXLData::stItem_Routing_Itemroutingvalue[0];

		upBasicPercent += getRandBetween(pRoutingValue->EFFECT_MIN, pRoutingValue->EFFECT_MAX);
#endif

		ItemRoutingValueResource::Flyweight * pFly = Static::InstancePtr()->GetItemRoutingValueResource()->GetFly(0);

		upBasicPercent += getRandBetween(pFly->_EFFECT_MIN, pFly->_EFFECT_MAX);

		if (clsData.eff_value[0] > 0)
		{
			int addValue = clsData.eff_value[0] + (clsData.eff_value[0] * upBasicPercent / 100.0);
			clsData.eff_value[0] = addValue;
		}
	}

	// 추가 효과 성능 향상
	int upAddPercent = 0;
	for (int slot = 1; slot <= 2; slot++)
	{
		if (slot == 1)
		{
			if (this->isAccessary(clsData) || this->isUpstone(clsData))
			{
				upAddPercent = this->getItemRoutingValue(clsData, 2);
			}
			else	// 장신구가 아니라면 능력치를 조금 더 올린다.
			{
				upAddPercent = this->getItemRoutingValue(clsData, slot);
			}
		}
		else if (slot == 2)		// C등급 이상의 장신구만 추가 효과 발생
		{
			// C등급 이상의 장신구가 아니라면 Skip.
			if (false == this->isAccessary(clsData) || clsData.quality < ITEM_QUALITY_C)
			{
				continue;
			}

			// 강화석은 하나만 가능
			if (this->isUpstone(clsData))
			{
				continue;
			}

			// 2번 슬롯 효과 여부 결정
			int effectRate = this->getItemRoutingValue(clsData, 3);
			int randRate = rand() % 100;

			if (effectRate < randRate)
			{
				continue;
			}

			upAddPercent = this->getItemRoutingValue(clsData, slot);
		}

		// 추가 효과 타입 결정
		int effectType = this->getAdditionalEffectType(clsData);

		// 추가 효과 값 계산
		int effectValue = this->getAdditionalEffectValue(clsData, effectType, upAddPercent, slot);

		// 추가 효과 값 타입 결정 (+ or %)
		int effectPos = this->getAdditionalEffectPos(effectType);

		clsData.eff_type[slot] = effectType;
		clsData.eff_pos[slot] = effectPos;

		if (effectType == ITEM_EFFECT_CONSUME_SP
				|| effectType == ITEM_EFFECT_COOL_TIME)
		{
			// SP소모나 기술쿨타임인 경우 음수값으로 설정
			effectValue = 0 - effectValue;
		}
		else if (effectType == ITEM_EFFECT_ACC
				|| effectType == ITEM_EFFECT_AVOID
				|| effectType == ITEM_EFFECT_CRI
				|| effectType == ITEM_EFFECT_CRI_DAMAGE)
		{
			// 정확도, 회피율, 크리율, 크리데미지인 경우 클라이언트에서 부동 소수점으로 표현하기위해 효과값 * 100
			effectValue = effectValue * 100;
		}

		clsData.eff_value[slot] = effectValue;
	}
}

int
ItemResource::getAdditionalEffectType(NLogic::Item::Data & clsData)
{
	/*
	 * 아이템 추가 효과 타입 결정
	 */



	// 5성 이상 아이템(강화석 포함)인 경우
	// 5성 이상 아이템에 부여되는 효과(OVER_A_TYPE == 1)중에서 확률을 계산하여 결정한다.
	if (clsData.quality >= ITEM_QUALITY_A)
	{
		int effectType = -1;
		int accRate = 0;
		int randRate = rand() % Static::Instance().GetItemRoutingRateResource()->GetTotalRate();

		ItemRoutingRateResource::ITEMROUTINGRATETREE & clsFlyTree = Static::Instance().GetItemRoutingRateResource()->GetTree();

		auto iter = clsFlyTree.begin();

		for (; iter != clsFlyTree.end(); ++iter)
		{
			if (1 != iter->second->_OVER_A_TYPE)
				continue;

			accRate += iter->second->_RATE;

			if (randRate < accRate)
			{
				effectType = iter->second->_EFFECT_TYPE;
				break;
			}
		}

		return effectType;
	}

	// 5성 미만 강화석인 경우
	// 효과값이 1이상인 효과중에서 랜덤하게 선택한다.
	if (true == this->isUpstone(clsData))
	{
		std::vector<int> effectTypeVector;
		ItemRoutingRateResource::ITEMROUTINGRATETREE & clsFlyTree = Static::Instance().GetItemRoutingRateResource()->GetTree();

		auto iter = clsFlyTree.begin();

		for (; iter != clsFlyTree.end(); ++iter)
		{
			int tmpValue = 0;

			switch (clsData.quality)
			{
			case 0: tmpValue = iter->second->_QUALITY1; break;
			case 1: tmpValue = iter->second->_QUALITY2; break;
			case 2: tmpValue = iter->second->_QUALITY3; break;
			case 3: tmpValue = iter->second->_QUALITY4; break;
			case 4: tmpValue = iter->second->_QUALITY5; break;
			case 5: tmpValue = iter->second->_QUALITY6; break;
			case 6: tmpValue = iter->second->_QUALITY7; break;
			case 7: tmpValue = iter->second->_QUALITY8; break;
			case 8: tmpValue = iter->second->_QUALITY9; break;
			case 9: tmpValue = iter->second->_QUALITY10; break;
			}

			if (tmpValue > 0)
			{
				effectTypeVector.push_back(iter->second->_EFFECT_TYPE);
			}
		}

		int vectorIndex = rand() % static_cast<int>(effectTypeVector.size());
		int effectType = effectTypeVector[vectorIndex];

		return effectType;
	}

	// 5성 미만 아이템은 ItemRoutingType테이블을 참조하여 효과를 결정한다.
	NResource::ItemRoutingTypeResource::Key	clsKey;

	if (clsData.sub_type == CLASS_ITEM_TABLE_WEAPONE)
	{
		clsKey.sheetType = clsData.sub_type;
		clsKey.classType = clsData.class_type;
	}
	else
	{
		clsKey.sheetType = clsData.sub_type;
		clsKey.classType = -1;
	}

	int effectType = -1;

	ItemRoutingTypeResource::Flyweight * pFly = Static::InstancePtr()->GetItemRoutingTypeResource()->GetFly(clsKey);
	if (NULL == pFly)
	{
		DEBUGLOG("(%s) sheetType : %d class Type : %d", __FUNCTION__, clsKey.sheetType, clsKey.classType);
		return effectType;
	}

	int randValue = (rand() % pFly->_EFFECT_COUNT) + 1;



	switch (randValue)
	{
	case 1: effectType = pFly->_EFFECT_TYPE1; break;
	case 2: effectType = pFly->_EFFECT_TYPE2; break;
	case 3: effectType = pFly->_EFFECT_TYPE3; break;
	case 4: effectType = pFly->_EFFECT_TYPE4; break;
	case 5: effectType = pFly->_EFFECT_TYPE5; break;
	case 6: effectType = pFly->_EFFECT_TYPE6; break;
	case 7: effectType = pFly->_EFFECT_TYPE7; break;
	case 8: effectType = pFly->_EFFECT_TYPE8; break;
	case 9: effectType = pFly->_EFFECT_TYPE9; break;
	case 10: effectType = pFly->_EFFECT_TYPE10; break;
	}

	return effectType;



#if 0
	int effectType = -1;

	if (this->isUpstone(clsData))	// 강화석
	{
		std::vector< int > typeVector;

		for (int i = 0; i < NXLData::ITEM_ROUTING_ITEMROUTINGRATE_MAX; i++)
		{
			int type = -1;
			const NXLData::ITEM_ROUTING_ITEMROUTINGRATE * pRoutingRate = &NXLData::stItem_Routing_Itemroutingrate[i];

			switch (clsData.quality)
			{
			case 0: type = pRoutingRate->F_RATE > 0 ? i : -1;	break;
			case 1: type = pRoutingRate->D_RATE > 0 ? i : -1;	break;
			case 2: type = pRoutingRate->C_RATE > 0 ? i : -1;	break;
			case 3: type = pRoutingRate->B_RATE > 0 ? i : -1;	break;
			case 4: type = pRoutingRate->A_RATE > 0 ? i : -1;	break;
			case 5: type = pRoutingRate->S_RATE > 0 ? i : -1;	break;
			case 6: type = pRoutingRate->SP_RATE > 0 ? i : -1;	break;
			case 7: type = pRoutingRate->SS_RATE > 0 ? i : -1;	break;
			case 8: type = pRoutingRate->SSP_RATE > 0 ? i : -1;	break;
			case 9: type = pRoutingRate->SSS_RATE > 0 ? i : -1;	break;
			}

			if (type >= 0)
				typeVector.push_back(type);
		}

		int vectorSize = static_cast<int>(typeVector.size());
		int vectorIndex = rand() % vectorSize;
		effectType = typeVector[vectorIndex];
	}
	// A등급 이상인 아이템은 ItemRoutingRate 테이블에 세팅된 효과 중에서 랜덤 선택한다.
	else if (clsData.quality >= ITEM_QUALITY_A)
	{
		std::vector< int > typeVector;

		for (int i = 0; i < NXLData::ITEM_ROUTING_ITEMROUTINGRATE_MAX; i++)
		{
			const NXLData::ITEM_ROUTING_ITEMROUTINGRATE * pRoutingRate = &NXLData::stItem_Routing_Itemroutingrate[i];
			if (pRoutingRate->OVER_A_TYPE == 1)
			{
				typeVector.push_back(i);
			}
		}

		int vectorSize = static_cast<int>(typeVector.size());
		int vectorIndex = rand() % vectorSize;
		effectType = typeVector[vectorIndex];
	}
	else
	{
		// A등급 미만 아이템은 ItemRoutingType 테이블을 참조하여 효과를 결정한다.
		int typeSheetIndex = 0;

		if (clsData.sub_type == CLASS_ITEM_TABLE_WEAPONE)
		{
			typeSheetIndex = clsData.class_type;
		}
		else
		{
			//------------------------------------------------------
			// Changed by spencer(2014.07.02)
			// 성기사 클래스 추가 open/close에 따른 처리
			//------------------------------------------------------
			int iClassCount = EnumCharClass::CLASS_TYPE_MAX;
			if ( false == NResource::Static::Instance().GetContentsOpenResource()->IsOpen(ContentsOpen::NEW_CLASS_PALADIN) )
				iClassCount -= 1;

			typeSheetIndex = clsData.sub_type + (iClassCount - 1);
		}


		const NXLData::ITEM_ROUTING_ITEMROUTINGTYPE * pRoutingType = &NXLData::stItem_Routing_Itemroutingtype[typeSheetIndex];

		int randValue = (rand() % pRoutingType->EFFECT_COUNT) + 1;

		switch (randValue)
		{
		case 1: effectType = pRoutingType->EFFECT_TYPE1; break;
		case 2: effectType = pRoutingType->EFFECT_TYPE2; break;
		case 3: effectType = pRoutingType->EFFECT_TYPE3; break;
		case 4: effectType = pRoutingType->EFFECT_TYPE4; break;
		case 5: effectType = pRoutingType->EFFECT_TYPE5; break;
		case 6: effectType = pRoutingType->EFFECT_TYPE6; break;
		case 7: effectType = pRoutingType->EFFECT_TYPE7; break;
		case 8: effectType = pRoutingType->EFFECT_TYPE8; break;
		case 9: effectType = pRoutingType->EFFECT_TYPE9; break;
		case 10: effectType = pRoutingType->EFFECT_TYPE10; break;
		}
	}

	return effectType;
#endif
}

int
ItemResource::getAdditionalEffectValue(NLogic::Item::Data & clsData, int effectType, int upAddPercent, int slotIndex)
{
	/*
	 * 아이템 추가 효과 값 결정
	 */

	ItemRoutingRateResource::Flyweight * pFly = Static::Instance().GetItemRoutingRateResource()->GetFly(effectType);

	int nValue = -1;

	switch (clsData.quality)
	{
	case ITEM_QUALITY_F: nValue = pFly->_QUALITY1; break;
	case ITEM_QUALITY_D: nValue = pFly->_QUALITY2; break;
	case ITEM_QUALITY_C: nValue = pFly->_QUALITY3; break;
	case ITEM_QUALITY_B: nValue = pFly->_QUALITY4; break;
	case ITEM_QUALITY_A: nValue = pFly->_QUALITY5; break;
	case ITEM_QUALITY_S: nValue = pFly->_QUALITY6; break;
	case ITEM_QUALITY_SP: nValue = pFly->_QUALITY7; break;
	case ITEM_QUALITY_SS: nValue = pFly->_QUALITY8; break;
	case ITEM_QUALITY_SSP: nValue = pFly->_QUALITY9; break;
	case ITEM_QUALITY_SSS: nValue = pFly->_QUALITY10; break;
	}

	int effectValue = -1;

	// 5성 이상 아이템에서 추가되는 효과는 ItemRoutingRate 테이블의 값을 그대로 사용
	if (effectType >= ITEM_EFFECT_QUALITY_A_MAX)
	{
		effectValue = nValue;
	}
	else
	{
		// 5성 미만 아이템은 ItemRoutingRate 테이블의 값을 가중치로 부여하여 계산한다.
		int levelWeightConst = pFly->_LEVEL_CONST;

		ItemRoutingValueResource::Flyweight * pFly = Static::InstancePtr()->GetItemRoutingValueResource()->GetFly(slotIndex);

		upAddPercent += nValue;
		upAddPercent += getRandBetween(pFly->_EFFECT_MIN, pFly->_EFFECT_MAX);
		effectValue = upAddPercent * ( (100 + clsData.level * levelWeightConst) / 200.0);
	}


#if 0
	const NXLData::ITEM_ROUTING_ITEMROUTINGRATE * pRoutingRate = &NXLData::stItem_Routing_Itemroutingrate[effectType];

	int nValue = -1;

	switch (clsData.quality)
	{
	case ITEM_QUALITY_F: nValue = pRoutingRate->F_RATE; break;
	case ITEM_QUALITY_D: nValue = pRoutingRate->D_RATE; break;
	case ITEM_QUALITY_C: nValue = pRoutingRate->C_RATE; break;
	case ITEM_QUALITY_B: nValue = pRoutingRate->B_RATE; break;
	case ITEM_QUALITY_A: nValue = pRoutingRate->A_RATE; break;
	case ITEM_QUALITY_S: nValue = pRoutingRate->S_RATE; break;
	case ITEM_QUALITY_SP: nValue = pRoutingRate->SP_RATE; break;
	case ITEM_QUALITY_SS: nValue = pRoutingRate->SS_RATE; break;
	case ITEM_QUALITY_SSP: nValue = pRoutingRate->SSP_RATE; break;
	case ITEM_QUALITY_SSS: nValue = pRoutingRate->SSS_RATE; break;
	}

	int effectValue = -1;

	// A등급 이상에서 추가되는 효과는 ItemRoutingRate 테이블의 값을 그대로 사용
	if (effectType >= ITEM_EFFECT_QUALITY_A_MAX)
	{
		effectValue = nValue;
	}
	else
	{
		// A등급 미만의 아이템은 ItemRoutingRate 테이블의 값을 가중치로 부여하여 계산한다.
		int levelWeightConst = pRoutingRate->LEVEL_CONST;

		const NXLData::ITEM_ROUTING_ITEMROUTINGVALUE * pRoutingValue= &NXLData::stItem_Routing_Itemroutingvalue[slotIndex];

		upAddPercent += nValue;
		upAddPercent += getRandBetween(pRoutingValue->EFFECT_MIN, pRoutingValue->EFFECT_MAX);
		effectValue = upAddPercent * ( (100 + clsData.level * levelWeightConst) / 200.0);
	}
#endif

	// 최소값은 1이상이어야 함.
	return effectValue > 1 ? effectValue : 1;

}

int
ItemResource::getAdditionalEffectPos(int effectType)
{
	/*
	 * 아이템 추가 효과 적용 위치 결정 ( + or % )
	 */

	ItemRoutingRateResource::Flyweight * pFly = Static::Instance().GetItemRoutingRateResource()->GetFly(effectType);

	return pFly->_VALUE_TYPE;

#if 0
	const NXLData::ITEM_ROUTING_ITEMROUTINGRATE * pRoutingRate = &NXLData::stItem_Routing_Itemroutingrate[effectType];

	return pRoutingRate->VALUE_TYPE;
#endif
}

int
ItemResource::getItemRoutingValue(NLogic::Item::Data & clsData, int slotIndex)
{
	ItemRoutingValueResource::Flyweight * pFly = Static::InstancePtr()->GetItemRoutingValueResource()->GetFly(slotIndex);

	switch (clsData.quality)
	{
	case ITEM_QUALITY_F:	return pFly->_QUALITY1;
	case ITEM_QUALITY_D:	return pFly->_QUALITY2;
	case ITEM_QUALITY_C:	return pFly->_QUALITY3;
	case ITEM_QUALITY_B:	return pFly->_QUALITY4;
	case ITEM_QUALITY_A:	return pFly->_QUALITY5;
	case ITEM_QUALITY_S:	return pFly->_QUALITY6;
	case ITEM_QUALITY_SP:	return pFly->_QUALITY7;
	case ITEM_QUALITY_SS:	return pFly->_QUALITY8;
	case ITEM_QUALITY_SSP:	return pFly->_QUALITY9;
	case ITEM_QUALITY_SSS:	return pFly->_QUALITY10;
	}

#if 0
	const NXLData::ITEM_ROUTING_ITEMROUTINGVALUE * pRoutingValue = &NXLData::stItem_Routing_Itemroutingvalue[slotIndex];

	switch (clsData.quality)
	{
	case ITEM_QUALITY_F:	return pRoutingValue->F_RATE;
	case ITEM_QUALITY_D:	return pRoutingValue->D_RATE;
	case ITEM_QUALITY_C:	return pRoutingValue->C_RATE;
	case ITEM_QUALITY_B:	return pRoutingValue->B_RATE;
	case ITEM_QUALITY_A:	return pRoutingValue->A_RATE;
	case ITEM_QUALITY_S:	return pRoutingValue->S_RATE;
	case ITEM_QUALITY_SP:	return pRoutingValue->SP_RATE;
	case ITEM_QUALITY_SS:	return pRoutingValue->SS_RATE;
	case ITEM_QUALITY_SSP:	return pRoutingValue->SSP_RATE;
	case ITEM_QUALITY_SSS:	return pRoutingValue->SSS_RATE;
	}
#endif

	return 0;
}

int
ItemResource::GetItemBagType(NLogic::Item::Data & clsData)
{
	Flyweight * pFly = getFly(clsData.sub_type, clsData.tid, clsData.class_type);
	if (NULL == pFly)
	{
		DEBUGLOG("%s : pFly is NULL! sub_type : %d, tid : %d, class_type : %d", __FUNCTION__,
				clsData.sub_type, clsData.tid, clsData.class_type);
		return -1;
	}
	return pFly->_BAGTYPE;

//	using namespace NXLData;
//
//	// for non-class type items
//	switch (clsData.sub_type)
//	{
//	case CLASS_ITEM_TABLE_NECKLACE:
//		return stItem_Common_Common_Necklace[clsData.tid].TYPE;
//	case CLASS_ITEM_TABLE_CLOAK:
//		return stItem_Common_Commonitem_Cloak[clsData.tid].TYPE;
//	case CLASS_ITEM_TABLE_RING:
//		return stItem_Common_Commonitem_Ring[clsData.tid].TYPE;
//	case CLASS_ITEM_TABLE_CHARM:
//		return stItem_Common_Commonitem_Charm[clsData.tid].TYPE;
//	case CLASS_ITEM_TABLE_TITLE:
//		return stItem_Common_Commonitem_Title[clsData.tid].TYPE;
//	case CLASS_ITEM_TABLE_CHARGE:
//		return stItem_Common_Commonitem_Charge[clsData.tid].TYPE;
//	case CLASS_ITEM_TABLE_QUEST:
//		return stItem_Common_Commonitem_Quest[clsData.tid].TYPE;
//	case CLASS_ITEM_TABLE_ETC:
//		return stItem_Common_Commonitem_Etc[clsData.tid].TYPE;
//	case CLASS_ITEM_TABLE_VEHICLE:
//		return stItem_Common_Commonitem_Vehicle[clsData.tid].TYPE;
//	case CLASS_ITEM_TABLE_BATTLE_PET :
//		return stItem_Common_Commonitem_Pet[clsData.tid].TYPE;
//	}
//
//
//	if (clsData.class_type == CLASS_TYPE_SLASHER)
//	{
//		switch (clsData.sub_type)
//		{
//		case CLASS_ITEM_TABLE_WEAPONE:
//			return stItem_Class1_Weapon01[clsData.tid].TYPE;
//		case CLASS_ITEM_TABLE_HELMET:
//			return stItem_Class1_Helmet01[clsData.tid].TYPE;
//		case CLASS_ITEM_TABLE_ARMOR:
//			return stItem_Class1_Armor01[clsData.tid].TYPE;
//		case CLASS_ITEM_TABLE_GLOVES:
//			return stItem_Class1_Gloves01[clsData.tid].TYPE;
//		case CLASS_ITEM_TABLE_SHOES:
//			return stItem_Class1_Shoes01[clsData.tid].TYPE;
//		case CLASS_ITEM_TABLE_AVATAR :
//			return stItem_Class1_Avatar01[clsData.tid].TYPE;
//		}
//	}
//	else if (clsData.class_type == CLASS_TYPE_RANGER)
//	{
//		switch (clsData.sub_type)
//		{
//		case CLASS_ITEM_TABLE_WEAPONE:
//			return stItem_Class2_Weapon02[clsData.tid].TYPE;
//		case CLASS_ITEM_TABLE_HELMET:
//			return stItem_Class2_Helmet02[clsData.tid].TYPE;
//		case CLASS_ITEM_TABLE_ARMOR:
//			return stItem_Class2_Armor02[clsData.tid].TYPE;
//		case CLASS_ITEM_TABLE_GLOVES:
//			return stItem_Class2_Gloves02[clsData.tid].TYPE;
//		case CLASS_ITEM_TABLE_SHOES:
//			return stItem_Class2_Shoes02[clsData.tid].TYPE;
//		case CLASS_ITEM_TABLE_AVATAR :
//			return stItem_Class2_Avatar02[clsData.tid].TYPE;
//		}
//	}
//	else if (clsData.class_type == CLASS_TYPE_FIGHTER)
//	{
//		switch (clsData.sub_type)
//		{
//		case CLASS_ITEM_TABLE_WEAPONE:
//		    return stItem_Class3_Weapon03[clsData.tid].TYPE;
//		case CLASS_ITEM_TABLE_HELMET:
//		    return stItem_Class3_Helmet03[clsData.tid].TYPE;
//		case CLASS_ITEM_TABLE_ARMOR:
//		    return stItem_Class3_Armor03[clsData.tid].TYPE;
//		case CLASS_ITEM_TABLE_GLOVES:
//		    return stItem_Class3_Gloves03[clsData.tid].TYPE;
//		case CLASS_ITEM_TABLE_SHOES:
//		    return stItem_Class3_Shoes03[clsData.tid].TYPE;
//		case CLASS_ITEM_TABLE_AVATAR :
//			return stItem_Class3_Avatar03[clsData.tid].TYPE;
//		}
//	}
//	else if (clsData.class_type == CLASS_TYPE_MAGICIAN)
//	{
//		switch (clsData.sub_type)
//		{
//		case CLASS_ITEM_TABLE_WEAPONE:
//		    return stItem_Class4_Weapon04[clsData.tid].TYPE;
//		case CLASS_ITEM_TABLE_HELMET:
//		    return stItem_Class4_Helmet04[clsData.tid].TYPE;
//		case CLASS_ITEM_TABLE_ARMOR:
//		    return stItem_Class4_Armor04[clsData.tid].TYPE;
//		case CLASS_ITEM_TABLE_GLOVES:
//		    return stItem_Class4_Gloves04[clsData.tid].TYPE;
//		case CLASS_ITEM_TABLE_SHOES:
//		    return stItem_Class4_Shoes04[clsData.tid].TYPE;
//		case CLASS_ITEM_TABLE_AVATAR :
//			return stItem_Class4_Avatar04[clsData.tid].TYPE;
//		}
//	}
//	else if (clsData.class_type == CLASS_TYPE_ASSASSIN)
//	{
//		switch (clsData.sub_type)
//		{
//		case CLASS_ITEM_TABLE_WEAPONE:
//		    return stItem_Class5_Weapon05[clsData.tid].TYPE;
//		case CLASS_ITEM_TABLE_HELMET:
//		    return stItem_Class5_Helmet05[clsData.tid].TYPE;
//		case CLASS_ITEM_TABLE_ARMOR:
//		    return stItem_Class5_Armor05[clsData.tid].TYPE;
//		case CLASS_ITEM_TABLE_GLOVES:
//		    return stItem_Class5_Gloves05[clsData.tid].TYPE;
//		case CLASS_ITEM_TABLE_SHOES:
//		    return stItem_Class5_Shoes05[clsData.tid].TYPE;
//		case CLASS_ITEM_TABLE_AVATAR :
//			return stItem_Class5_Avatar05[clsData.tid].TYPE;
//		}
//	}

//	return 0;
}

int
ItemResource::GetItemPrice(NLogic::Item::Data & clsData)
{
	Flyweight * pFly = getFly(clsData.sub_type, clsData.tid, clsData.class_type);
	if (NULL == pFly)
	{
		DEBUGLOG("%s : pFly is NULL! sub_type : %d, tid : %d, class_type : %d", __FUNCTION__,
				clsData.sub_type, clsData.tid, clsData.class_type);
		return -1;
	}
	return pFly->_PRICE;
//	using namespace NXLData;
//
//	// for non-class type items
//	switch (clsData.sub_type)
//	{
//	case CLASS_ITEM_TABLE_NECKLACE:
//		return stItem_Common_Common_Necklace[clsData.tid].PRICE;
//	case CLASS_ITEM_TABLE_CLOAK:
//		return stItem_Common_Commonitem_Cloak[clsData.tid].PRICE;
//	case CLASS_ITEM_TABLE_RING:
//		return stItem_Common_Commonitem_Ring[clsData.tid].PRICE;
//	case CLASS_ITEM_TABLE_CHARM:
//		return stItem_Common_Commonitem_Charm[clsData.tid].PRICE;
//	case CLASS_ITEM_TABLE_TITLE:
//		return stItem_Common_Commonitem_Title[clsData.tid].PRICE;
//	case CLASS_ITEM_TABLE_CHARGE:
//		return stItem_Common_Commonitem_Charge[clsData.tid].PRICE;
//	case CLASS_ITEM_TABLE_QUEST:
//		return stItem_Common_Commonitem_Quest[clsData.tid].PRICE;
//	case CLASS_ITEM_TABLE_ETC:
//		return stItem_Common_Commonitem_Etc[clsData.tid].PRICE;
//	case CLASS_ITEM_TABLE_VEHICLE:
//		return stItem_Common_Commonitem_Vehicle[clsData.tid].PRICE;
//	case CLASS_ITEM_TABLE_BATTLE_PET :
//		return stItem_Common_Commonitem_Pet[clsData.tid].PRICE;
//	}
//
//
//	if (clsData.class_type == CLASS_TYPE_SLASHER)
//	{
//		switch (clsData.sub_type)
//		{
//		case CLASS_ITEM_TABLE_WEAPONE:
//			return stItem_Class1_Weapon01[clsData.tid].PRICE;
//		case CLASS_ITEM_TABLE_HELMET:
//			return stItem_Class1_Helmet01[clsData.tid].PRICE;
//		case CLASS_ITEM_TABLE_ARMOR:
//			return stItem_Class1_Armor01[clsData.tid].PRICE;
//		case CLASS_ITEM_TABLE_GLOVES:
//			return stItem_Class1_Gloves01[clsData.tid].PRICE;
//		case CLASS_ITEM_TABLE_SHOES:
//			return stItem_Class1_Shoes01[clsData.tid].PRICE;
//		case CLASS_ITEM_TABLE_AVATAR :
//			return stItem_Class1_Avatar01[clsData.tid].PRICE;
//		}
//	}
//	else if (clsData.class_type == CLASS_TYPE_RANGER)
//	{
//		switch (clsData.sub_type)
//		{
//		case CLASS_ITEM_TABLE_WEAPONE:
//			return stItem_Class2_Weapon02[clsData.tid].PRICE;
//		case CLASS_ITEM_TABLE_HELMET:
//			return stItem_Class2_Helmet02[clsData.tid].PRICE;
//		case CLASS_ITEM_TABLE_ARMOR:
//			return stItem_Class2_Armor02[clsData.tid].PRICE;
//		case CLASS_ITEM_TABLE_GLOVES:
//			return stItem_Class2_Gloves02[clsData.tid].PRICE;
//		case CLASS_ITEM_TABLE_SHOES:
//			return stItem_Class2_Shoes02[clsData.tid].PRICE;
//		case CLASS_ITEM_TABLE_AVATAR :
//			return stItem_Class2_Avatar02[clsData.tid].PRICE;
//		}
//	}
//	else if (clsData.class_type == CLASS_TYPE_FIGHTER)
//	{
//		switch (clsData.sub_type)
//		{
//		case CLASS_ITEM_TABLE_WEAPONE:
//		    return stItem_Class3_Weapon03[clsData.tid].PRICE;
//		case CLASS_ITEM_TABLE_HELMET:
//		    return stItem_Class3_Helmet03[clsData.tid].PRICE;
//		case CLASS_ITEM_TABLE_ARMOR:
//		    return stItem_Class3_Armor03[clsData.tid].PRICE;
//		case CLASS_ITEM_TABLE_GLOVES:
//		    return stItem_Class3_Gloves03[clsData.tid].PRICE;
//		case CLASS_ITEM_TABLE_SHOES:
//		    return stItem_Class3_Shoes03[clsData.tid].PRICE;
//		case CLASS_ITEM_TABLE_AVATAR :
//			return stItem_Class3_Avatar03[clsData.tid].PRICE;
//		}
//	}
//	else if (clsData.class_type == CLASS_TYPE_MAGICIAN)
//	{
//		switch (clsData.sub_type)
//		{
//		case CLASS_ITEM_TABLE_WEAPONE:
//		    return stItem_Class4_Weapon04[clsData.tid].PRICE;
//		case CLASS_ITEM_TABLE_HELMET:
//		    return stItem_Class4_Helmet04[clsData.tid].PRICE;
//		case CLASS_ITEM_TABLE_ARMOR:
//		    return stItem_Class4_Armor04[clsData.tid].PRICE;
//		case CLASS_ITEM_TABLE_GLOVES:
//		    return stItem_Class4_Gloves04[clsData.tid].PRICE;
//		case CLASS_ITEM_TABLE_SHOES:
//		    return stItem_Class4_Shoes04[clsData.tid].PRICE;
//		case CLASS_ITEM_TABLE_AVATAR :
//			return stItem_Class4_Avatar04[clsData.tid].PRICE;
//		}
//	}
//	else if (clsData.class_type == CLASS_TYPE_ASSASSIN)
//	{
//		switch (clsData.sub_type)
//		{
//		case CLASS_ITEM_TABLE_WEAPONE:
//		    return stItem_Class5_Weapon05[clsData.tid].PRICE;
//		case CLASS_ITEM_TABLE_HELMET:
//		    return stItem_Class5_Helmet05[clsData.tid].PRICE;
//		case CLASS_ITEM_TABLE_ARMOR:
//		    return stItem_Class5_Armor05[clsData.tid].PRICE;
//		case CLASS_ITEM_TABLE_GLOVES:
//		    return stItem_Class5_Gloves05[clsData.tid].PRICE;
//		case CLASS_ITEM_TABLE_SHOES:
//		    return stItem_Class5_Shoes05[clsData.tid].PRICE;
//		case CLASS_ITEM_TABLE_AVATAR :
//			return stItem_Class5_Avatar05[clsData.tid].PRICE;
//		}
//	}

//	return 0;
}


int
ItemResource::GetItemDurability(NLogic::Item::Data & clsData)
{
	Flyweight * pFly = getFly(clsData.sub_type, clsData.tid, clsData.class_type);
	if (NULL == pFly)
	{
		DEBUGLOG("%s : pFly is NULL! sub_type : %d, tid : %d, class_type : %d", __FUNCTION__,
				clsData.sub_type, clsData.tid, clsData.class_type);
		return -1;
	}
	return pFly->_DURABILITY;
//	using namespace NXLData;
//
//	// for non-class type items
//	switch (clsData.sub_type)
//	{
//	case CLASS_ITEM_TABLE_NECKLACE:
//		return stItem_Common_Common_Necklace[clsData.tid].DURABILITY;
//	case CLASS_ITEM_TABLE_CLOAK:
//		return stItem_Common_Commonitem_Cloak[clsData.tid].DURABILITY;
//	case CLASS_ITEM_TABLE_RING:
//		return stItem_Common_Commonitem_Ring[clsData.tid].DURABILITY;
//	case CLASS_ITEM_TABLE_CHARM:
//		return stItem_Common_Commonitem_Charm[clsData.tid].DURABILITY;
//	case CLASS_ITEM_TABLE_TITLE:
//		return stItem_Common_Commonitem_Title[clsData.tid].DURABILITY;
//	case CLASS_ITEM_TABLE_CHARGE:
//		return stItem_Common_Commonitem_Charge[clsData.tid].DURABILITY;
//	case CLASS_ITEM_TABLE_QUEST:
//		return stItem_Common_Commonitem_Quest[clsData.tid].DURABILITY;
//	case CLASS_ITEM_TABLE_ETC:
//		return stItem_Common_Commonitem_Etc[clsData.tid].DURABILITY;
//	case CLASS_ITEM_TABLE_VEHICLE:
//		return stItem_Common_Commonitem_Vehicle[clsData.tid].DURABILITY;
//	case CLASS_ITEM_TABLE_BATTLE_PET :
//		return stItem_Common_Commonitem_Pet[clsData.tid].DURABILITY;
//	}
//
//
//	if (clsData.class_type == CLASS_TYPE_SLASHER)
//	{
//		switch (clsData.sub_type)
//		{
//		case CLASS_ITEM_TABLE_WEAPONE:
//			return stItem_Class1_Weapon01[clsData.tid].DURABILITY;
//		case CLASS_ITEM_TABLE_HELMET:
//			return stItem_Class1_Helmet01[clsData.tid].DURABILITY;
//		case CLASS_ITEM_TABLE_ARMOR:
//			return stItem_Class1_Armor01[clsData.tid].DURABILITY;
//		case CLASS_ITEM_TABLE_GLOVES:
//			return stItem_Class1_Gloves01[clsData.tid].DURABILITY;
//		case CLASS_ITEM_TABLE_SHOES:
//			return stItem_Class1_Shoes01[clsData.tid].DURABILITY;
//		case CLASS_ITEM_TABLE_AVATAR :
//			return stItem_Class1_Avatar01[clsData.tid].DURABILITY;
//		}
//	}
//	else if (clsData.class_type == CLASS_TYPE_RANGER)
//	{
//		switch (clsData.sub_type)
//		{
//		case CLASS_ITEM_TABLE_WEAPONE:
//			return stItem_Class2_Weapon02[clsData.tid].DURABILITY;
//		case CLASS_ITEM_TABLE_HELMET:
//			return stItem_Class2_Helmet02[clsData.tid].DURABILITY;
//		case CLASS_ITEM_TABLE_ARMOR:
//			return stItem_Class2_Armor02[clsData.tid].DURABILITY;
//		case CLASS_ITEM_TABLE_GLOVES:
//			return stItem_Class2_Gloves02[clsData.tid].DURABILITY;
//		case CLASS_ITEM_TABLE_SHOES:
//			return stItem_Class2_Shoes02[clsData.tid].DURABILITY;
//		case CLASS_ITEM_TABLE_AVATAR :
//			return stItem_Class2_Avatar02[clsData.tid].DURABILITY;
//		}
//	}
//	else if (clsData.class_type == CLASS_TYPE_FIGHTER)
//	{
//		switch (clsData.sub_type)
//		{
//		case CLASS_ITEM_TABLE_WEAPONE:
//		    return stItem_Class3_Weapon03[clsData.tid].DURABILITY;
//		case CLASS_ITEM_TABLE_HELMET:
//		    return stItem_Class3_Helmet03[clsData.tid].DURABILITY;
//		case CLASS_ITEM_TABLE_ARMOR:
//		    return stItem_Class3_Armor03[clsData.tid].DURABILITY;
//		case CLASS_ITEM_TABLE_GLOVES:
//		    return stItem_Class3_Gloves03[clsData.tid].DURABILITY;
//		case CLASS_ITEM_TABLE_SHOES:
//		    return stItem_Class3_Shoes03[clsData.tid].DURABILITY;
//		case CLASS_ITEM_TABLE_AVATAR :
//			return stItem_Class3_Avatar03[clsData.tid].DURABILITY;
//		}
//	}
//	else if (clsData.class_type == CLASS_TYPE_MAGICIAN)
//	{
//		switch (clsData.sub_type)
//		{
//		case CLASS_ITEM_TABLE_WEAPONE:
//		    return stItem_Class4_Weapon04[clsData.tid].DURABILITY;
//		case CLASS_ITEM_TABLE_HELMET:
//		    return stItem_Class4_Helmet04[clsData.tid].DURABILITY;
//		case CLASS_ITEM_TABLE_ARMOR:
//		    return stItem_Class4_Armor04[clsData.tid].DURABILITY;
//		case CLASS_ITEM_TABLE_GLOVES:
//		    return stItem_Class4_Gloves04[clsData.tid].DURABILITY;
//		case CLASS_ITEM_TABLE_SHOES:
//		    return stItem_Class4_Shoes04[clsData.tid].DURABILITY;
//		case CLASS_ITEM_TABLE_AVATAR :
//			return stItem_Class4_Avatar04[clsData.tid].DURABILITY;
//		}
//	}
//	else if (clsData.class_type == CLASS_TYPE_ASSASSIN)
//	{
//		switch (clsData.sub_type)
//		{
//		case CLASS_ITEM_TABLE_WEAPONE:
//		    return stItem_Class5_Weapon05[clsData.tid].DURABILITY;
//		case CLASS_ITEM_TABLE_HELMET:
//		    return stItem_Class5_Helmet05[clsData.tid].DURABILITY;
//		case CLASS_ITEM_TABLE_ARMOR:
//		    return stItem_Class5_Armor05[clsData.tid].DURABILITY;
//		case CLASS_ITEM_TABLE_GLOVES:
//		    return stItem_Class5_Gloves05[clsData.tid].DURABILITY;
//		case CLASS_ITEM_TABLE_SHOES:
//		    return stItem_Class5_Shoes05[clsData.tid].DURABILITY;
//		case CLASS_ITEM_TABLE_AVATAR :
//			return stItem_Class5_Avatar05[clsData.tid].DURABILITY;
//		}
//	}

//	return 0;
}


int
ItemResource::GetItemLevel(NLogic::Item::Data & clsData)
{
	Flyweight * pFly = getFly(clsData.sub_type, clsData.tid, clsData.class_type);
	if (NULL == pFly)
	{
		DEBUGLOG("%s : pFly is NULL! sub_type : %d, tid : %d, class_type : %d", __FUNCTION__,
				clsData.sub_type, clsData.tid, clsData.class_type);
		return -1;
	}
	return pFly->_LIMIT_LEVEL;

//	using namespace NXLData;
//
//	// for non-class type items
//	switch (clsData.sub_type)
//	{
//	case CLASS_ITEM_TABLE_NECKLACE:
//		return stItem_Common_Common_Necklace[clsData.tid].LIMIT_LEVEL;
//	case CLASS_ITEM_TABLE_CLOAK:
//		return stItem_Common_Commonitem_Cloak[clsData.tid].LIMIT_LEVEL;
//	case CLASS_ITEM_TABLE_RING:
//		return stItem_Common_Commonitem_Ring[clsData.tid].LIMIT_LEVEL;
//	case CLASS_ITEM_TABLE_CHARM:
//		return stItem_Common_Commonitem_Charm[clsData.tid].LIMIT_LEVEL;
//	case CLASS_ITEM_TABLE_TITLE:
//		return stItem_Common_Commonitem_Title[clsData.tid].LIMIT_LEVEL;
//	case CLASS_ITEM_TABLE_CHARGE:
//		return stItem_Common_Commonitem_Charge[clsData.tid].LIMIT_LEVEL;
//	case CLASS_ITEM_TABLE_QUEST:
//		return stItem_Common_Commonitem_Quest[clsData.tid].LIMIT_LEVEL;
//	case CLASS_ITEM_TABLE_ETC:
//		return stItem_Common_Commonitem_Etc[clsData.tid].LIMIT_LEVEL;
//	case CLASS_ITEM_TABLE_VEHICLE:
//		return stItem_Common_Commonitem_Vehicle[clsData.tid].LIMIT_LEVEL;
//	case CLASS_ITEM_TABLE_BATTLE_PET :
//		return stItem_Common_Commonitem_Pet[clsData.tid].LIMIT_LEVEL;
//	}
//
//
//	if (clsData.class_type == CLASS_TYPE_SLASHER)
//	{
//		switch (clsData.sub_type)
//		{
//		case CLASS_ITEM_TABLE_WEAPONE:
//			return stItem_Class1_Weapon01[clsData.tid].LIMIT_LEVEL;
//		case CLASS_ITEM_TABLE_HELMET:
//			return stItem_Class1_Helmet01[clsData.tid].LIMIT_LEVEL;
//		case CLASS_ITEM_TABLE_ARMOR:
//			return stItem_Class1_Armor01[clsData.tid].LIMIT_LEVEL;
//		case CLASS_ITEM_TABLE_GLOVES:
//			return stItem_Class1_Gloves01[clsData.tid].LIMIT_LEVEL;
//		case CLASS_ITEM_TABLE_SHOES:
//			return stItem_Class1_Shoes01[clsData.tid].LIMIT_LEVEL;
//		case CLASS_ITEM_TABLE_AVATAR :
//			return stItem_Class1_Avatar01[clsData.tid].LIMIT_LEVEL;
//		}
//	}
//	else if (clsData.class_type == CLASS_TYPE_RANGER)
//	{
//		switch (clsData.sub_type)
//		{
//		case CLASS_ITEM_TABLE_WEAPONE:
//			return stItem_Class2_Weapon02[clsData.tid].LIMIT_LEVEL;
//		case CLASS_ITEM_TABLE_HELMET:
//			return stItem_Class2_Helmet02[clsData.tid].LIMIT_LEVEL;
//		case CLASS_ITEM_TABLE_ARMOR:
//			return stItem_Class2_Armor02[clsData.tid].LIMIT_LEVEL;
//		case CLASS_ITEM_TABLE_GLOVES:
//			return stItem_Class2_Gloves02[clsData.tid].LIMIT_LEVEL;
//		case CLASS_ITEM_TABLE_SHOES:
//			return stItem_Class2_Shoes02[clsData.tid].LIMIT_LEVEL;
//		case CLASS_ITEM_TABLE_AVATAR :
//			return stItem_Class2_Avatar02[clsData.tid].LIMIT_LEVEL;
//		}
//	}
//	else if (clsData.class_type == CLASS_TYPE_FIGHTER)
//	{
//		switch (clsData.sub_type)
//		{
//		case CLASS_ITEM_TABLE_WEAPONE:
//		    return stItem_Class3_Weapon03[clsData.tid].LIMIT_LEVEL;
//		case CLASS_ITEM_TABLE_HELMET:
//		    return stItem_Class3_Helmet03[clsData.tid].LIMIT_LEVEL;
//		case CLASS_ITEM_TABLE_ARMOR:
//		    return stItem_Class3_Armor03[clsData.tid].LIMIT_LEVEL;
//		case CLASS_ITEM_TABLE_GLOVES:
//		    return stItem_Class3_Gloves03[clsData.tid].LIMIT_LEVEL;
//		case CLASS_ITEM_TABLE_SHOES:
//		    return stItem_Class3_Shoes03[clsData.tid].LIMIT_LEVEL;
//		case CLASS_ITEM_TABLE_AVATAR :
//			return stItem_Class3_Avatar03[clsData.tid].LIMIT_LEVEL;
//		}
//	}
//	else if (clsData.class_type == CLASS_TYPE_MAGICIAN)
//	{
//		switch (clsData.sub_type)
//		{
//		case CLASS_ITEM_TABLE_WEAPONE:
//		    return stItem_Class4_Weapon04[clsData.tid].LIMIT_LEVEL;
//		case CLASS_ITEM_TABLE_HELMET:
//		    return stItem_Class4_Helmet04[clsData.tid].LIMIT_LEVEL;
//		case CLASS_ITEM_TABLE_ARMOR:
//		    return stItem_Class4_Armor04[clsData.tid].LIMIT_LEVEL;
//		case CLASS_ITEM_TABLE_GLOVES:
//		    return stItem_Class4_Gloves04[clsData.tid].LIMIT_LEVEL;
//		case CLASS_ITEM_TABLE_SHOES:
//		    return stItem_Class4_Shoes04[clsData.tid].LIMIT_LEVEL;
//		case CLASS_ITEM_TABLE_AVATAR :
//			return stItem_Class4_Avatar04[clsData.tid].LIMIT_LEVEL;
//		}
//	}
//	else if (clsData.class_type == CLASS_TYPE_ASSASSIN)
//	{
//		switch (clsData.sub_type)
//		{
//		case CLASS_ITEM_TABLE_WEAPONE:
//		    return stItem_Class5_Weapon05[clsData.tid].LIMIT_LEVEL;
//		case CLASS_ITEM_TABLE_HELMET:
//		    return stItem_Class5_Helmet05[clsData.tid].LIMIT_LEVEL;
//		case CLASS_ITEM_TABLE_ARMOR:
//		    return stItem_Class5_Armor05[clsData.tid].LIMIT_LEVEL;
//		case CLASS_ITEM_TABLE_GLOVES:
//		    return stItem_Class5_Gloves05[clsData.tid].LIMIT_LEVEL;
//		case CLASS_ITEM_TABLE_SHOES:
//		    return stItem_Class5_Shoes05[clsData.tid].LIMIT_LEVEL;
//		case CLASS_ITEM_TABLE_AVATAR :
//			return stItem_Class5_Avatar05[clsData.tid].LIMIT_LEVEL;
//		}
//	}

//	return 0;
}


void
ItemResource::setItemEffect(NLogic::Item::Data & clsData)
{
	Flyweight * pFly = getFly(clsData.sub_type, clsData.tid, clsData.class_type);
	if (NULL == pFly)
	{
		DEBUGLOG("%s : pFly is NULL! sub_type : %d, tid : %d, class_type : %d", __FUNCTION__,
				clsData.sub_type, clsData.tid, clsData.class_type);
		clsData.eff_type[0]	= -1;
		clsData.eff_value[0]	= 0;
		clsData.eff_pos[0]		= -1;
		return;
	}
	clsData.eff_type[0]	= pFly->_EFFECT;
	clsData.eff_value[0]	= pFly->_EFF_VALUE;
	clsData.eff_pos[0]	= pFly->_EFF_POS;

//	using namespace NXLData;
//
//	// for non-class type items
//	switch (clsData.sub_type)
//	{
//	case CLASS_ITEM_TABLE_NECKLACE:
//		clsData.eff_type[0] 	= stItem_Common_Common_Necklace[clsData.tid].EFFECT;
//		clsData.eff_value[0] 	= stItem_Common_Common_Necklace[clsData.tid].EFF_VALUE;
//		clsData.eff_pos[0] 	= stItem_Common_Common_Necklace[clsData.tid].EFF_POS;
//		return;
//	case CLASS_ITEM_TABLE_CLOAK:
//		clsData.eff_type[0] 	= stItem_Common_Commonitem_Cloak[clsData.tid].EFFECT;
//		clsData.eff_value[0] 	= stItem_Common_Commonitem_Cloak[clsData.tid].EFF_VALUE;
//		clsData.eff_pos[0] 	= stItem_Common_Commonitem_Cloak[clsData.tid].EFF_POS;
//		return;
//	case CLASS_ITEM_TABLE_RING:
//		clsData.eff_type[0] 	= stItem_Common_Commonitem_Ring[clsData.tid].EFFECT;
//		clsData.eff_value[0] 	= stItem_Common_Commonitem_Ring[clsData.tid].EFF_VALUE;
//		clsData.eff_pos[0] 	= stItem_Common_Commonitem_Ring[clsData.tid].EFF_POS;
//		return;
//	case CLASS_ITEM_TABLE_CHARM:
//		clsData.eff_type[0] 	= stItem_Common_Commonitem_Charm[clsData.tid].EFFECT;
//		clsData.eff_value[0] 	= stItem_Common_Commonitem_Charm[clsData.tid].EFF_VALUE;
//		clsData.eff_pos[0] 	= stItem_Common_Commonitem_Charm[clsData.tid].EFF_POS;
//		return;
//	case CLASS_ITEM_TABLE_TITLE:
//		clsData.eff_type[0] 	= stItem_Common_Commonitem_Title[clsData.tid].EFFECT;
//		clsData.eff_value[0] 	= stItem_Common_Commonitem_Title[clsData.tid].EFF_VALUE;
//		clsData.eff_pos[0] 	= stItem_Common_Commonitem_Title[clsData.tid].EFF_POS;
//		return;
//	case CLASS_ITEM_TABLE_CHARGE:
//		clsData.eff_type[0] 	= stItem_Common_Commonitem_Charge[clsData.tid].EFFECT;
//		clsData.eff_value[0] 	= stItem_Common_Commonitem_Charge[clsData.tid].EFF_VALUE;
//		clsData.eff_pos[0] 	= stItem_Common_Commonitem_Charge[clsData.tid].EFF_POS;
//		return;
//	case CLASS_ITEM_TABLE_QUEST:
//		clsData.eff_type[0] 	= stItem_Common_Commonitem_Quest[clsData.tid].EFFECT;
//		clsData.eff_value[0]	= stItem_Common_Commonitem_Quest[clsData.tid].EFF_VALUE;
//		clsData.eff_pos[0] 	= stItem_Common_Commonitem_Quest[clsData.tid].EFF_POS;
//		return;
//	case CLASS_ITEM_TABLE_ETC:
//		clsData.eff_type[0]	= stItem_Common_Commonitem_Etc[clsData.tid].EFFECT;
//		clsData.eff_value[0]	= stItem_Common_Commonitem_Etc[clsData.tid].EFF_VALUE;
//		clsData.eff_pos[0]		= stItem_Common_Commonitem_Etc[clsData.tid].EFF_POS;
//		return;
//	case CLASS_ITEM_TABLE_VEHICLE:
//		clsData.eff_type[0]	= stItem_Common_Commonitem_Vehicle[clsData.tid].EFFECT;
//		clsData.eff_value[0]	= stItem_Common_Commonitem_Vehicle[clsData.tid].EFF_VALUE;
//		clsData.eff_pos[0]		= stItem_Common_Commonitem_Vehicle[clsData.tid].EFF_POS;
//		return;
//	case CLASS_ITEM_TABLE_BATTLE_PET :
//		clsData.eff_type[0]	= stItem_Common_Commonitem_Pet[clsData.tid].EFFECT;
//		clsData.eff_value[0]	= stItem_Common_Commonitem_Pet[clsData.tid].EFF_VALUE;
//		clsData.eff_pos[0]		= stItem_Common_Commonitem_Pet[clsData.tid].EFF_POS;
//		return;
//	}
//
//	// for class type item
//	if (clsData.class_type == CLASS_TYPE_SLASHER)
//	{
//		switch (clsData.sub_type)
//		{
//		case CLASS_ITEM_TABLE_WEAPONE:
//			clsData.eff_type[0] 	= stItem_Class1_Weapon01[clsData.tid].EFFECT;
//			clsData.eff_value[0] 	= stItem_Class1_Weapon01[clsData.tid].EFF_VALUE;
//			clsData.eff_pos[0] 	= stItem_Class1_Weapon01[clsData.tid].EFF_POS;
//			return;
//		case CLASS_ITEM_TABLE_HELMET:
//			clsData.eff_type[0] 	= stItem_Class1_Helmet01[clsData.tid].EFFECT;
//			clsData.eff_value[0] 	= stItem_Class1_Helmet01[clsData.tid].EFF_VALUE;
//			clsData.eff_pos[0] 	= stItem_Class1_Helmet01[clsData.tid].EFF_POS;
//			return;
//		case CLASS_ITEM_TABLE_ARMOR:
//			clsData.eff_type[0] 	= stItem_Class1_Armor01[clsData.tid].EFFECT;
//			clsData.eff_value[0] 	= stItem_Class1_Armor01[clsData.tid].EFF_VALUE;
//			clsData.eff_pos[0] 	= stItem_Class1_Armor01[clsData.tid].EFF_POS;
//			return;
//		case CLASS_ITEM_TABLE_GLOVES:
//			clsData.eff_type[0] 	= stItem_Class1_Gloves01[clsData.tid].EFFECT;
//			clsData.eff_value[0] 	= stItem_Class1_Gloves01[clsData.tid].EFF_VALUE;
//			clsData.eff_pos[0] 	= stItem_Class1_Gloves01[clsData.tid].EFF_POS;
//			return;
//		case CLASS_ITEM_TABLE_SHOES:
//			clsData.eff_type[0] 	= stItem_Class1_Shoes01[clsData.tid].EFFECT;
//			clsData.eff_value[0] 	= stItem_Class1_Shoes01[clsData.tid].EFF_VALUE;
//			clsData.eff_pos[0] 	= stItem_Class1_Shoes01[clsData.tid].EFF_POS;
//			return;
//		case CLASS_ITEM_TABLE_AVATAR :
//			clsData.eff_type[0]	= stItem_Class1_Avatar01[clsData.tid].EFFECT;
//			clsData.eff_value[0]	= stItem_Class1_Avatar01[clsData.tid].EFF_VALUE;
//			clsData.eff_pos[0]		= stItem_Class1_Avatar01[clsData.tid].EFF_POS;
//			return;
//		}
//	}
//	else if (clsData.class_type == CLASS_TYPE_RANGER)
//	{
//	   switch (clsData.sub_type)
//		{
//		case CLASS_ITEM_TABLE_WEAPONE:
//			clsData.eff_type[0]    = stItem_Class2_Weapon02[clsData.tid].EFFECT;
//			clsData.eff_value[0]   = stItem_Class2_Weapon02[clsData.tid].EFF_VALUE;
//			clsData.eff_pos[0]     = stItem_Class2_Weapon02[clsData.tid].EFF_POS;
//			return;
//		case CLASS_ITEM_TABLE_HELMET:
//			clsData.eff_type[0]    = stItem_Class2_Helmet02[clsData.tid].EFFECT;
//			clsData.eff_value[0]   = stItem_Class2_Helmet02[clsData.tid].EFF_VALUE;
//			clsData.eff_pos[0]     = stItem_Class2_Helmet02[clsData.tid].EFF_POS;
//			return;
//		case CLASS_ITEM_TABLE_ARMOR:
//			clsData.eff_type[0]    = stItem_Class2_Armor02[clsData.tid].EFFECT;
//			clsData.eff_value[0]   = stItem_Class2_Armor02[clsData.tid].EFF_VALUE;
//			clsData.eff_pos[0]     = stItem_Class2_Armor02[clsData.tid].EFF_POS;
//			return;
//		case CLASS_ITEM_TABLE_GLOVES:
//			clsData.eff_type[0]    = stItem_Class2_Gloves02[clsData.tid].EFFECT;
//			clsData.eff_value[0]   = stItem_Class2_Gloves02[clsData.tid].EFF_VALUE;
//			clsData.eff_pos[0]     = stItem_Class2_Gloves02[clsData.tid].EFF_POS;
//			return;
//		case CLASS_ITEM_TABLE_SHOES:
//			clsData.eff_type[0]    = stItem_Class2_Shoes02[clsData.tid].EFFECT;
//			clsData.eff_value[0]   = stItem_Class2_Shoes02[clsData.tid].EFF_VALUE;
//			clsData.eff_pos[0]     = stItem_Class2_Shoes02[clsData.tid].EFF_POS;
//			return;
//		case CLASS_ITEM_TABLE_AVATAR :
//			clsData.eff_type[0]	= stItem_Class2_Avatar02[clsData.tid].EFFECT;
//			clsData.eff_value[0]	= stItem_Class2_Avatar02[clsData.tid].EFF_VALUE;
//			clsData.eff_pos[0]		= stItem_Class2_Avatar02[clsData.tid].EFF_POS;
//			return;
//		}
//	}
//	else if (clsData.class_type == CLASS_TYPE_FIGHTER)
//	{
//		switch (clsData.sub_type)
//		{
//		case CLASS_ITEM_TABLE_WEAPONE:
//		    clsData.eff_type[0]    = stItem_Class3_Weapon03[clsData.tid].EFFECT;
//		    clsData.eff_value[0]   = stItem_Class3_Weapon03[clsData.tid].EFF_VALUE;
//		    clsData.eff_pos[0]     = stItem_Class3_Weapon03[clsData.tid].EFF_POS;
//		    return;
//		case CLASS_ITEM_TABLE_HELMET:
//		    clsData.eff_type[0]    = stItem_Class3_Helmet03[clsData.tid].EFFECT;
//		    clsData.eff_value[0]   = stItem_Class3_Helmet03[clsData.tid].EFF_VALUE;
//		    clsData.eff_pos[0]     = stItem_Class3_Helmet03[clsData.tid].EFF_POS;
//		    return;
//		case CLASS_ITEM_TABLE_ARMOR:
//		    clsData.eff_type[0]    = stItem_Class3_Armor03[clsData.tid].EFFECT;
//		    clsData.eff_value[0]   = stItem_Class3_Armor03[clsData.tid].EFF_VALUE;
//		    clsData.eff_pos[0]     = stItem_Class3_Armor03[clsData.tid].EFF_POS;
//		    return;
//		case CLASS_ITEM_TABLE_GLOVES:
//		    clsData.eff_type[0]    = stItem_Class3_Gloves03[clsData.tid].EFFECT;
//		    clsData.eff_value[0]   = stItem_Class3_Gloves03[clsData.tid].EFF_VALUE;
//		    clsData.eff_pos[0]     = stItem_Class3_Gloves03[clsData.tid].EFF_POS;
//		    return;
//		case CLASS_ITEM_TABLE_SHOES:
//		    clsData.eff_type[0]    = stItem_Class3_Shoes03[clsData.tid].EFFECT;
//		    clsData.eff_value[0]   = stItem_Class3_Shoes03[clsData.tid].EFF_VALUE;
//		    clsData.eff_pos[0]     = stItem_Class3_Shoes03[clsData.tid].EFF_POS;
//		    return;
//		case CLASS_ITEM_TABLE_AVATAR :
//			clsData.eff_type[0]	= stItem_Class3_Avatar03[clsData.tid].EFFECT;
//			clsData.eff_value[0]	= stItem_Class3_Avatar03[clsData.tid].EFF_VALUE;
//			clsData.eff_pos[0]		= stItem_Class3_Avatar03[clsData.tid].EFF_POS;
//			return;
//		}
//	}
//	else if (clsData.class_type == CLASS_TYPE_MAGICIAN)
//	{
//		switch (clsData.sub_type)
//		{
//		case CLASS_ITEM_TABLE_WEAPONE:
//		    clsData.eff_type[0]    = stItem_Class4_Weapon04[clsData.tid].EFFECT;
//		    clsData.eff_value[0]   = stItem_Class4_Weapon04[clsData.tid].EFF_VALUE;
//		    clsData.eff_pos[0]     = stItem_Class4_Weapon04[clsData.tid].EFF_POS;
//		    return;
//		case CLASS_ITEM_TABLE_HELMET:
//		    clsData.eff_type[0]    = stItem_Class4_Helmet04[clsData.tid].EFFECT;
//		    clsData.eff_value[0]   = stItem_Class4_Helmet04[clsData.tid].EFF_VALUE;
//		    clsData.eff_pos[0]     = stItem_Class4_Helmet04[clsData.tid].EFF_POS;
//		    return;
//		case CLASS_ITEM_TABLE_ARMOR:
//		    clsData.eff_type[0]    = stItem_Class4_Armor04[clsData.tid].EFFECT;
//		    clsData.eff_value[0]   = stItem_Class4_Armor04[clsData.tid].EFF_VALUE;
//		    clsData.eff_pos[0]     = stItem_Class4_Armor04[clsData.tid].EFF_POS;
//		    return;
//		case CLASS_ITEM_TABLE_GLOVES:
//		    clsData.eff_type[0]    = stItem_Class4_Gloves04[clsData.tid].EFFECT;
//		    clsData.eff_value[0]   = stItem_Class4_Gloves04[clsData.tid].EFF_VALUE;
//		    clsData.eff_pos[0]     = stItem_Class4_Gloves04[clsData.tid].EFF_POS;
//		    return;
//		case CLASS_ITEM_TABLE_SHOES:
//		    clsData.eff_type[0]    = stItem_Class4_Shoes04[clsData.tid].EFFECT;
//		    clsData.eff_value[0]   = stItem_Class4_Shoes04[clsData.tid].EFF_VALUE;
//		    clsData.eff_pos[0]     = stItem_Class4_Shoes04[clsData.tid].EFF_POS;
//		    return;
//		case CLASS_ITEM_TABLE_AVATAR :
//			clsData.eff_type[0]	= stItem_Class4_Avatar04[clsData.tid].EFFECT;
//			clsData.eff_value[0]	= stItem_Class4_Avatar04[clsData.tid].EFF_VALUE;
//			clsData.eff_pos[0]		= stItem_Class4_Avatar04[clsData.tid].EFF_POS;
//			return;
//		}
//	}
//	else if (clsData.class_type == CLASS_TYPE_ASSASSIN)
//	{
//		switch (clsData.sub_type)
//		{
//		case CLASS_ITEM_TABLE_WEAPONE:
//		    clsData.eff_type[0]    = stItem_Class5_Weapon05[clsData.tid].EFFECT;
//		    clsData.eff_value[0]   = stItem_Class5_Weapon05[clsData.tid].EFF_VALUE;
//		    clsData.eff_pos[0]     = stItem_Class5_Weapon05[clsData.tid].EFF_POS;
//		    return;
//		case CLASS_ITEM_TABLE_HELMET:
//		    clsData.eff_type[0]    = stItem_Class5_Helmet05[clsData.tid].EFFECT;
//		    clsData.eff_value[0]   = stItem_Class5_Helmet05[clsData.tid].EFF_VALUE;
//		    clsData.eff_pos[0]     = stItem_Class5_Helmet05[clsData.tid].EFF_POS;
//		    return;
//		case CLASS_ITEM_TABLE_ARMOR:
//		    clsData.eff_type[0]    = stItem_Class5_Armor05[clsData.tid].EFFECT;
//		    clsData.eff_value[0]   = stItem_Class5_Armor05[clsData.tid].EFF_VALUE;
//		    clsData.eff_pos[0]     = stItem_Class5_Armor05[clsData.tid].EFF_POS;
//		    return;
//		case CLASS_ITEM_TABLE_GLOVES:
//		    clsData.eff_type[0]    = stItem_Class5_Gloves05[clsData.tid].EFFECT;
//		    clsData.eff_value[0]   = stItem_Class5_Gloves05[clsData.tid].EFF_VALUE;
//		    clsData.eff_pos[0]     = stItem_Class5_Gloves05[clsData.tid].EFF_POS;
//		    return;
//		case CLASS_ITEM_TABLE_SHOES:
//		    clsData.eff_type[0]    = stItem_Class5_Shoes05[clsData.tid].EFFECT;
//		    clsData.eff_value[0]   = stItem_Class5_Shoes05[clsData.tid].EFF_VALUE;
//		    clsData.eff_pos[0]     = stItem_Class5_Shoes05[clsData.tid].EFF_POS;
//		    return;
//		case CLASS_ITEM_TABLE_AVATAR :
//			clsData.eff_type[0]	= stItem_Class5_Avatar05[clsData.tid].EFFECT;
//			clsData.eff_value[0]	= stItem_Class5_Avatar05[clsData.tid].EFF_VALUE;
//			clsData.eff_pos[0]		= stItem_Class5_Avatar05[clsData.tid].EFF_POS;
//			return;
//		}
//	}

//	clsData.eff_type[0]	= -1;
//	clsData.eff_value[0]	= 0;
//	clsData.eff_pos[0]		= -1;
}

int
ItemResource::GetClassType(User * pUser, int tid, int sheet_type)
{
	if (sheet_type > CLASS_ITEM_TABLE_MAX)
	{
		return -1;
	}

	return pUser->GetCharacterInfo().classtype;


//	using namespace NXLData;
//
//	switch (sheet_type) {
//	case CLASS_ITEM_TABLE_NECKLACE:
//		return stItem_Common_Common_Necklace[tid].CHARCLASSTYPE;
//	case CLASS_ITEM_TABLE_CLOAK:
//		return stItem_Common_Commonitem_Cloak[tid].CHARCLASSTYPE;
//	case CLASS_ITEM_TABLE_RING:
//		return stItem_Common_Commonitem_Ring[tid].CHARCLASSTYPE;
//	case CLASS_ITEM_TABLE_CHARM:
//		return stItem_Common_Commonitem_Charm[tid].CHARCLASSTYPE;
//	case CLASS_ITEM_TABLE_TITLE:
//		return stItem_Common_Commonitem_Title[tid].CHARCLASSTYPE;
//	case CLASS_ITEM_TABLE_CHARGE:
//		return stItem_Common_Commonitem_Charge[tid].CHARCLASSTYPE;
//	case CLASS_ITEM_TABLE_QUEST:
//		return stItem_Common_Commonitem_Quest[tid].CHARCLASSTYPE;
//	case CLASS_ITEM_TABLE_ETC:
//		return stItem_Common_Commonitem_Etc[tid].CHARCLASSTYPE;
//	case CLASS_ITEM_TABLE_VEHICLE:
//		return stItem_Common_Commonitem_Vehicle[tid].CHARCLASSTYPE;
//	case CLASS_ITEM_TABLE_BATTLE_PET :
//		return stItem_Common_Commonitem_Pet[tid].CHARCLASSTYPE;
//	default:
//		return pUser->GetCharacterInfo().classtype;
//	}

//	return 0;
}

int
ItemResource::GetItemSubType(NLogic::Item::Data & clsData)
{
	Flyweight * pFly = getFly(clsData.sub_type, clsData.tid, clsData.class_type);
	if (NULL == pFly)
	{
		DEBUGLOG("%s : pFly is NULL! sub_type : %d, tid : %d, class_type : %d", __FUNCTION__,
				clsData.sub_type, clsData.tid, clsData.class_type);
		return -1;
	}

	return pFly->_SUBTYPE;


//	using namespace NXLData;
//
//	// for non-class type items
//	switch (clsData.sub_type)
//	{
//	case CLASS_ITEM_TABLE_NECKLACE:
//		return stItem_Common_Common_Necklace[clsData.tid].SUBTYPE;
//	case CLASS_ITEM_TABLE_CLOAK:
//		return stItem_Common_Commonitem_Cloak[clsData.tid].SUBTYPE;
//	case CLASS_ITEM_TABLE_RING:
//		return stItem_Common_Commonitem_Ring[clsData.tid].SUBTYPE;
//	case CLASS_ITEM_TABLE_CHARM:
//		return stItem_Common_Commonitem_Charm[clsData.tid].SUBTYPE;
//	case CLASS_ITEM_TABLE_TITLE:
//		return stItem_Common_Commonitem_Title[clsData.tid].SUBTYPE;
//	case CLASS_ITEM_TABLE_CHARGE:
//		return stItem_Common_Commonitem_Charge[clsData.tid].SUBTYPE;
//	case CLASS_ITEM_TABLE_QUEST:
//		return stItem_Common_Commonitem_Quest[clsData.tid].SUBTYPE;
//	case CLASS_ITEM_TABLE_ETC:
//		return stItem_Common_Commonitem_Etc[clsData.tid].SUBTYPE;
//	case CLASS_ITEM_TABLE_VEHICLE:
//		return stItem_Common_Commonitem_Vehicle[clsData.tid].SUBTYPE;
//	case CLASS_ITEM_TABLE_BATTLE_PET :
//		return stItem_Common_Commonitem_Pet[clsData.tid].SUBTYPE;
//	}
//
//
//	if (clsData.class_type == CLASS_TYPE_SLASHER)
//	{
//		switch (clsData.sub_type)
//		{
//		case CLASS_ITEM_TABLE_WEAPONE:
//			return stItem_Class1_Weapon01[clsData.tid].SUBTYPE;
//		case CLASS_ITEM_TABLE_HELMET:
//			return stItem_Class1_Helmet01[clsData.tid].SUBTYPE;
//		case CLASS_ITEM_TABLE_ARMOR:
//			return stItem_Class1_Armor01[clsData.tid].SUBTYPE;
//		case CLASS_ITEM_TABLE_GLOVES:
//			return stItem_Class1_Gloves01[clsData.tid].SUBTYPE;
//		case CLASS_ITEM_TABLE_SHOES:
//			return stItem_Class1_Shoes01[clsData.tid].SUBTYPE;
//		case CLASS_ITEM_TABLE_AVATAR :
//			return stItem_Class1_Avatar01[clsData.tid].SUBTYPE;
//		}
//	}
//	else if (clsData.class_type == CLASS_TYPE_RANGER)
//	{
//		switch (clsData.sub_type)
//		{
//		case CLASS_ITEM_TABLE_WEAPONE:
//			return stItem_Class2_Weapon02[clsData.tid].SUBTYPE;
//		case CLASS_ITEM_TABLE_HELMET:
//			return stItem_Class2_Helmet02[clsData.tid].SUBTYPE;
//		case CLASS_ITEM_TABLE_ARMOR:
//			return stItem_Class2_Armor02[clsData.tid].SUBTYPE;
//		case CLASS_ITEM_TABLE_GLOVES:
//			return stItem_Class2_Gloves02[clsData.tid].SUBTYPE;
//		case CLASS_ITEM_TABLE_SHOES:
//			return stItem_Class2_Shoes02[clsData.tid].SUBTYPE;
//		case CLASS_ITEM_TABLE_AVATAR :
//			return stItem_Class2_Avatar02[clsData.tid].SUBTYPE;
//		}
//	}
//	else if (clsData.class_type == CLASS_TYPE_FIGHTER)
//	{
//		switch (clsData.sub_type)
//		{
//		case CLASS_ITEM_TABLE_WEAPONE:
//		    return stItem_Class3_Weapon03[clsData.tid].SUBTYPE;
//		case CLASS_ITEM_TABLE_HELMET:
//		    return stItem_Class3_Helmet03[clsData.tid].SUBTYPE;
//		case CLASS_ITEM_TABLE_ARMOR:
//		    return stItem_Class3_Armor03[clsData.tid].SUBTYPE;
//		case CLASS_ITEM_TABLE_GLOVES:
//		    return stItem_Class3_Gloves03[clsData.tid].SUBTYPE;
//		case CLASS_ITEM_TABLE_SHOES:
//		    return stItem_Class3_Shoes03[clsData.tid].SUBTYPE;
//		case CLASS_ITEM_TABLE_AVATAR :
//			return stItem_Class3_Avatar03[clsData.tid].SUBTYPE;
//		}
//	}
//	else if (clsData.class_type == CLASS_TYPE_MAGICIAN)
//	{
//		switch (clsData.sub_type)
//		{
//		case CLASS_ITEM_TABLE_WEAPONE:
//		    return stItem_Class4_Weapon04[clsData.tid].SUBTYPE;
//		case CLASS_ITEM_TABLE_HELMET:
//		    return stItem_Class4_Helmet04[clsData.tid].SUBTYPE;
//		case CLASS_ITEM_TABLE_ARMOR:
//		    return stItem_Class4_Armor04[clsData.tid].SUBTYPE;
//		case CLASS_ITEM_TABLE_GLOVES:
//		    return stItem_Class4_Gloves04[clsData.tid].SUBTYPE;
//		case CLASS_ITEM_TABLE_SHOES:
//		    return stItem_Class4_Shoes04[clsData.tid].SUBTYPE;
//		case CLASS_ITEM_TABLE_AVATAR :
//			return stItem_Class4_Avatar04[clsData.tid].SUBTYPE;
//		}
//	}
//	else if (clsData.class_type == CLASS_TYPE_ASSASSIN)
//	{
//		switch (clsData.sub_type)
//		{
//		case CLASS_ITEM_TABLE_WEAPONE:
//		    return stItem_Class5_Weapon05[clsData.tid].SUBTYPE;
//		case CLASS_ITEM_TABLE_HELMET:
//		    return stItem_Class5_Helmet05[clsData.tid].SUBTYPE;
//		case CLASS_ITEM_TABLE_ARMOR:
//		    return stItem_Class5_Armor05[clsData.tid].SUBTYPE;
//		case CLASS_ITEM_TABLE_GLOVES:
//		    return stItem_Class5_Gloves05[clsData.tid].SUBTYPE;
//		case CLASS_ITEM_TABLE_SHOES:
//		    return stItem_Class5_Shoes05[clsData.tid].SUBTYPE;
//		case CLASS_ITEM_TABLE_AVATAR :
//			return stItem_Class5_Avatar05[clsData.tid].SUBTYPE;
//		}
//	}

//	return 0;
}

int
ItemResource::getItemTradeType(const NLogic::Item::Data & clsData)
{
	Flyweight * pFly = getFly(clsData.sub_type, clsData.tid, clsData.class_type);
	if (NULL == pFly)
	{
		DEBUGLOG("%s : pFly is NULL! sub_type : %d, tid : %d, class_type : %d", __FUNCTION__,
				clsData.sub_type, clsData.tid, clsData.class_type);
		return -1;
	}
	return pFly->_ITEM_EXCHANGE;

//	using namespace NXLData;
//
//	// for non-class type items
//	switch (clsData.sub_type)
//	{
//	case CLASS_ITEM_TABLE_NECKLACE:
//		return stItem_Common_Common_Necklace[clsData.tid].ITEM_EXCHANGE;
//	case CLASS_ITEM_TABLE_CLOAK:
//		return stItem_Common_Commonitem_Cloak[clsData.tid].ITEM_EXCHANGE;
//	case CLASS_ITEM_TABLE_RING:
//		return stItem_Common_Commonitem_Ring[clsData.tid].ITEM_EXCHANGE;
//	case CLASS_ITEM_TABLE_CHARM:
//		return stItem_Common_Commonitem_Charm[clsData.tid].ITEM_EXCHANGE;
//	case CLASS_ITEM_TABLE_TITLE:
//		return stItem_Common_Commonitem_Title[clsData.tid].ITEM_EXCHANGE;
//	case CLASS_ITEM_TABLE_CHARGE:
//		return stItem_Common_Commonitem_Charge[clsData.tid].ITEM_EXCHANGE;
//	case CLASS_ITEM_TABLE_QUEST:
//		return stItem_Common_Commonitem_Quest[clsData.tid].ITEM_EXCHANGE;
//	case CLASS_ITEM_TABLE_ETC:
//		return stItem_Common_Commonitem_Etc[clsData.tid].ITEM_EXCHANGE;
//	case CLASS_ITEM_TABLE_VEHICLE:
//		return stItem_Common_Commonitem_Vehicle[clsData.tid].ITEM_EXCHANGE;
//	case CLASS_ITEM_TABLE_BATTLE_PET :
//		return stItem_Common_Commonitem_Pet[clsData.tid].ITEM_EXCHANGE;
//	}
//
//
//	if (clsData.class_type == CLASS_TYPE_SLASHER)
//	{
//		switch (clsData.sub_type)
//		{
//		case CLASS_ITEM_TABLE_WEAPONE:
//			return stItem_Class1_Weapon01[clsData.tid].ITEM_EXCHANGE;
//		case CLASS_ITEM_TABLE_HELMET:
//			return stItem_Class1_Helmet01[clsData.tid].ITEM_EXCHANGE;
//		case CLASS_ITEM_TABLE_ARMOR:
//			return stItem_Class1_Armor01[clsData.tid].ITEM_EXCHANGE;
//		case CLASS_ITEM_TABLE_GLOVES:
//			return stItem_Class1_Gloves01[clsData.tid].ITEM_EXCHANGE;
//		case CLASS_ITEM_TABLE_SHOES:
//			return stItem_Class1_Shoes01[clsData.tid].ITEM_EXCHANGE;
//		case CLASS_ITEM_TABLE_AVATAR :
//			return stItem_Class1_Avatar01[clsData.tid].ITEM_EXCHANGE;
//		}
//	}
//	else if (clsData.class_type == CLASS_TYPE_RANGER)
//	{
//		switch (clsData.sub_type)
//		{
//		case CLASS_ITEM_TABLE_WEAPONE:
//			return stItem_Class2_Weapon02[clsData.tid].ITEM_EXCHANGE;
//		case CLASS_ITEM_TABLE_HELMET:
//			return stItem_Class2_Helmet02[clsData.tid].ITEM_EXCHANGE;
//		case CLASS_ITEM_TABLE_ARMOR:
//			return stItem_Class2_Armor02[clsData.tid].ITEM_EXCHANGE;
//		case CLASS_ITEM_TABLE_GLOVES:
//			return stItem_Class2_Gloves02[clsData.tid].ITEM_EXCHANGE;
//		case CLASS_ITEM_TABLE_SHOES:
//			return stItem_Class2_Shoes02[clsData.tid].ITEM_EXCHANGE;
//		case CLASS_ITEM_TABLE_AVATAR :
//			return stItem_Class2_Avatar02[clsData.tid].ITEM_EXCHANGE;
//		}
//	}
//	else if (clsData.class_type == CLASS_TYPE_FIGHTER)
//	{
//		switch (clsData.sub_type)
//		{
//		case CLASS_ITEM_TABLE_WEAPONE:
//		    return stItem_Class3_Weapon03[clsData.tid].ITEM_EXCHANGE;
//		case CLASS_ITEM_TABLE_HELMET:
//		    return stItem_Class3_Helmet03[clsData.tid].ITEM_EXCHANGE;
//		case CLASS_ITEM_TABLE_ARMOR:
//		    return stItem_Class3_Armor03[clsData.tid].ITEM_EXCHANGE;
//		case CLASS_ITEM_TABLE_GLOVES:
//		    return stItem_Class3_Gloves03[clsData.tid].ITEM_EXCHANGE;
//		case CLASS_ITEM_TABLE_SHOES:
//		    return stItem_Class3_Shoes03[clsData.tid].ITEM_EXCHANGE;
//		case CLASS_ITEM_TABLE_AVATAR :
//			return stItem_Class3_Avatar03[clsData.tid].ITEM_EXCHANGE;
//		}
//	}
//	else if (clsData.class_type == CLASS_TYPE_MAGICIAN)
//	{
//		switch (clsData.sub_type)
//		{
//		case CLASS_ITEM_TABLE_WEAPONE:
//		    return stItem_Class4_Weapon04[clsData.tid].ITEM_EXCHANGE;
//		case CLASS_ITEM_TABLE_HELMET:
//		    return stItem_Class4_Helmet04[clsData.tid].ITEM_EXCHANGE;
//		case CLASS_ITEM_TABLE_ARMOR:
//		    return stItem_Class4_Armor04[clsData.tid].ITEM_EXCHANGE;
//		case CLASS_ITEM_TABLE_GLOVES:
//		    return stItem_Class4_Gloves04[clsData.tid].ITEM_EXCHANGE;
//		case CLASS_ITEM_TABLE_SHOES:
//		    return stItem_Class4_Shoes04[clsData.tid].ITEM_EXCHANGE;
//		case CLASS_ITEM_TABLE_AVATAR :
//			return stItem_Class4_Avatar04[clsData.tid].ITEM_EXCHANGE;
//		}
//	}
//	else if (clsData.class_type == CLASS_TYPE_ASSASSIN)
//	{
//		switch (clsData.sub_type)
//		{
//		case CLASS_ITEM_TABLE_WEAPONE:
//		    return stItem_Class5_Weapon05[clsData.tid].ITEM_EXCHANGE;
//		case CLASS_ITEM_TABLE_HELMET:
//		    return stItem_Class5_Helmet05[clsData.tid].ITEM_EXCHANGE;
//		case CLASS_ITEM_TABLE_ARMOR:
//		    return stItem_Class5_Armor05[clsData.tid].ITEM_EXCHANGE;
//		case CLASS_ITEM_TABLE_GLOVES:
//		    return stItem_Class5_Gloves05[clsData.tid].ITEM_EXCHANGE;
//		case CLASS_ITEM_TABLE_SHOES:
//		    return stItem_Class5_Shoes05[clsData.tid].ITEM_EXCHANGE;
//		case CLASS_ITEM_TABLE_AVATAR :
//			return stItem_Class5_Avatar05[clsData.tid].ITEM_EXCHANGE;
//		}
//	}

//	return 0;
}

int
ItemResource::getItemSaleType(const NLogic::Item::Data & clsData)
{
	Flyweight * pFly = getFly(clsData.sub_type, clsData.tid, clsData.class_type);
	if (NULL == pFly)
	{
		DEBUGLOG("%s : pFly is NULL! sub_type : %d, tid : %d, class_type : %d", __FUNCTION__,
				clsData.sub_type, clsData.tid, clsData.class_type);
		return -1;
	}
	return pFly->_SALE;
}

int
ItemResource::getItemStackType(const NLogic::Item::Data & clsData)
{
	Flyweight * pFly = getFly(clsData.sub_type, clsData.tid, clsData.class_type);
	if (NULL == pFly)
	{
		DEBUGLOG("%s : pFly is NULL! sub_type : %d, tid : %d, class_type : %d", __FUNCTION__,
				clsData.sub_type, clsData.tid, clsData.class_type);
		return -1;
	}
	return pFly->_STACK;
//	using namespace NXLData;
//
//	// for non-class type items
//	switch (clsData.sub_type)
//	{
//	case CLASS_ITEM_TABLE_NECKLACE:
//		return stItem_Common_Common_Necklace[clsData.tid].STACK;
//	case CLASS_ITEM_TABLE_CLOAK:
//		return stItem_Common_Commonitem_Cloak[clsData.tid].STACK;
//	case CLASS_ITEM_TABLE_RING:
//		return stItem_Common_Commonitem_Ring[clsData.tid].STACK;
//	case CLASS_ITEM_TABLE_CHARM:
//		return stItem_Common_Commonitem_Charm[clsData.tid].STACK;
//	case CLASS_ITEM_TABLE_TITLE:
//		return stItem_Common_Commonitem_Title[clsData.tid].STACK;
//	case CLASS_ITEM_TABLE_CHARGE:
//		return stItem_Common_Commonitem_Charge[clsData.tid].STACK;
//	case CLASS_ITEM_TABLE_QUEST:
//		return stItem_Common_Commonitem_Quest[clsData.tid].STACK;
//	case CLASS_ITEM_TABLE_ETC:
//		return stItem_Common_Commonitem_Etc[clsData.tid].STACK;
//	case CLASS_ITEM_TABLE_VEHICLE:
//		return stItem_Common_Commonitem_Vehicle[clsData.tid].STACK;
//	case CLASS_ITEM_TABLE_BATTLE_PET :
//		return stItem_Common_Commonitem_Pet[clsData.tid].STACK;
//	}
//
//
//	if (clsData.class_type == CLASS_TYPE_SLASHER)
//	{
//		switch (clsData.sub_type)
//		{
//		case CLASS_ITEM_TABLE_WEAPONE:
//			return stItem_Class1_Weapon01[clsData.tid].STACK;
//		case CLASS_ITEM_TABLE_HELMET:
//			return stItem_Class1_Helmet01[clsData.tid].STACK;
//		case CLASS_ITEM_TABLE_ARMOR:
//			return stItem_Class1_Armor01[clsData.tid].STACK;
//		case CLASS_ITEM_TABLE_GLOVES:
//			return stItem_Class1_Gloves01[clsData.tid].STACK;
//		case CLASS_ITEM_TABLE_SHOES:
//			return stItem_Class1_Shoes01[clsData.tid].STACK;
//		case CLASS_ITEM_TABLE_AVATAR :
//			return stItem_Class1_Avatar01[clsData.tid].STACK;
//		}
//	}
//	else if (clsData.class_type == CLASS_TYPE_RANGER)
//	{
//		switch (clsData.sub_type)
//		{
//		case CLASS_ITEM_TABLE_WEAPONE:
//			return stItem_Class2_Weapon02[clsData.tid].STACK;
//		case CLASS_ITEM_TABLE_HELMET:
//			return stItem_Class2_Helmet02[clsData.tid].STACK;
//		case CLASS_ITEM_TABLE_ARMOR:
//			return stItem_Class2_Armor02[clsData.tid].STACK;
//		case CLASS_ITEM_TABLE_GLOVES:
//			return stItem_Class2_Gloves02[clsData.tid].STACK;
//		case CLASS_ITEM_TABLE_SHOES:
//			return stItem_Class2_Shoes02[clsData.tid].STACK;
//		case CLASS_ITEM_TABLE_AVATAR :
//			return stItem_Class2_Avatar02[clsData.tid].STACK;
//		}
//	}
//	else if (clsData.class_type == CLASS_TYPE_FIGHTER)
//	{
//		switch (clsData.sub_type)
//		{
//		case CLASS_ITEM_TABLE_WEAPONE:
//		    return stItem_Class3_Weapon03[clsData.tid].STACK;
//		case CLASS_ITEM_TABLE_HELMET:
//		    return stItem_Class3_Helmet03[clsData.tid].STACK;
//		case CLASS_ITEM_TABLE_ARMOR:
//		    return stItem_Class3_Armor03[clsData.tid].STACK;
//		case CLASS_ITEM_TABLE_GLOVES:
//		    return stItem_Class3_Gloves03[clsData.tid].STACK;
//		case CLASS_ITEM_TABLE_SHOES:
//		    return stItem_Class3_Shoes03[clsData.tid].STACK;
//		case CLASS_ITEM_TABLE_AVATAR :
//			return stItem_Class3_Avatar03[clsData.tid].STACK;
//		}
//	}
//	else if (clsData.class_type == CLASS_TYPE_MAGICIAN)
//	{
//		switch (clsData.sub_type)
//		{
//		case CLASS_ITEM_TABLE_WEAPONE:
//		    return stItem_Class4_Weapon04[clsData.tid].STACK;
//		case CLASS_ITEM_TABLE_HELMET:
//		    return stItem_Class4_Helmet04[clsData.tid].STACK;
//		case CLASS_ITEM_TABLE_ARMOR:
//		    return stItem_Class4_Armor04[clsData.tid].STACK;
//		case CLASS_ITEM_TABLE_GLOVES:
//		    return stItem_Class4_Gloves04[clsData.tid].STACK;
//		case CLASS_ITEM_TABLE_SHOES:
//		    return stItem_Class4_Shoes04[clsData.tid].STACK;
//		case CLASS_ITEM_TABLE_AVATAR :
//			return stItem_Class4_Avatar04[clsData.tid].STACK;
//		}
//	}
//	else if (clsData.class_type == CLASS_TYPE_ASSASSIN)
//	{
//		switch (clsData.sub_type)
//		{
//		case CLASS_ITEM_TABLE_WEAPONE:
//		    return stItem_Class5_Weapon05[clsData.tid].STACK;
//		case CLASS_ITEM_TABLE_HELMET:
//		    return stItem_Class5_Helmet05[clsData.tid].STACK;
//		case CLASS_ITEM_TABLE_ARMOR:
//		    return stItem_Class5_Armor05[clsData.tid].STACK;
//		case CLASS_ITEM_TABLE_GLOVES:
//		    return stItem_Class5_Gloves05[clsData.tid].STACK;
//		case CLASS_ITEM_TABLE_SHOES:
//		    return stItem_Class5_Shoes05[clsData.tid].STACK;
//		case CLASS_ITEM_TABLE_AVATAR :
//			return stItem_Class5_Avatar05[clsData.tid].STACK;
//		}
//	}

//	return 0;
}


void
ItemResource::setItemEffectForCardReward(NLogic::Card::Data * pData)
{
	Flyweight * pFly = getFly(pData->sheetType, pData->tid, pData->classType);
	if (NULL == pFly)
	{
		DEBUGLOG("%s : pFly is NULL! sub_type : %d, tid : %d, class_type : %d", __FUNCTION__,
				pData->sheetType, pData->tid, pData->classType);
		pData->effType	= -1;
		pData->effValue	= 0;
		pData->effPos		= -1;
		return;
	}
	pData->effType	= pFly->_EFFECT;
	pData->effValue 	= pFly->_EFF_VALUE;
	pData->effPos		= pFly->_EFF_POS;

//	using namespace NXLData;
//
//	// for non-class type items
//	switch (pData->sheetType)
//	{
//	case CLASS_ITEM_TABLE_NECKLACE:
//		pData->effType 	= stItem_Common_Common_Necklace[pData->tid].EFFECT;
//		pData->effValue 	= stItem_Common_Common_Necklace[pData->tid].EFF_VALUE;
//		pData->effPos 	= stItem_Common_Common_Necklace[pData->tid].EFF_POS;
//		return;
//	case CLASS_ITEM_TABLE_CLOAK:
//		pData->effType 	= stItem_Common_Commonitem_Cloak[pData->tid].EFFECT;
//		pData->effValue 	= stItem_Common_Commonitem_Cloak[pData->tid].EFF_VALUE;
//		pData->effPos 	= stItem_Common_Commonitem_Cloak[pData->tid].EFF_POS;
//		return;
//	case CLASS_ITEM_TABLE_RING:
//		pData->effType 	= stItem_Common_Commonitem_Ring[pData->tid].EFFECT;
//		pData->effValue 	= stItem_Common_Commonitem_Ring[pData->tid].EFF_VALUE;
//		pData->effPos 	= stItem_Common_Commonitem_Ring[pData->tid].EFF_POS;
//		return;
//	case CLASS_ITEM_TABLE_CHARM:
//		pData->effType 	= stItem_Common_Commonitem_Charm[pData->tid].EFFECT;
//		pData->effValue 	= stItem_Common_Commonitem_Charm[pData->tid].EFF_VALUE;
//		pData->effPos 	= stItem_Common_Commonitem_Charm[pData->tid].EFF_POS;
//		return;
//	case CLASS_ITEM_TABLE_TITLE:
//		pData->effType 	= stItem_Common_Commonitem_Title[pData->tid].EFFECT;
//		pData->effValue 	= stItem_Common_Commonitem_Title[pData->tid].EFF_VALUE;
//		pData->effPos 	= stItem_Common_Commonitem_Title[pData->tid].EFF_POS;
//		return;
//	case CLASS_ITEM_TABLE_CHARGE:
//		pData->effType 	= stItem_Common_Commonitem_Charge[pData->tid].EFFECT;
//		pData->effValue 	= stItem_Common_Commonitem_Charge[pData->tid].EFF_VALUE;
//		pData->effPos 	= stItem_Common_Commonitem_Charge[pData->tid].EFF_POS;
//		return;
//	case CLASS_ITEM_TABLE_QUEST:
//		pData->effType 	= stItem_Common_Commonitem_Quest[pData->tid].EFFECT;
//		pData->effValue	= stItem_Common_Commonitem_Quest[pData->tid].EFF_VALUE;
//		pData->effPos 	= stItem_Common_Commonitem_Quest[pData->tid].EFF_POS;
//		return;
//	case CLASS_ITEM_TABLE_ETC:
//		pData->effType	= stItem_Common_Commonitem_Etc[pData->tid].EFFECT;
//		pData->effValue	= stItem_Common_Commonitem_Etc[pData->tid].EFF_VALUE;
//		pData->effPos		= stItem_Common_Commonitem_Etc[pData->tid].EFF_POS;
//		return;
//	case CLASS_ITEM_TABLE_VEHICLE:
//		pData->effType	= stItem_Common_Commonitem_Vehicle[pData->tid].EFFECT;
//		pData->effValue	= stItem_Common_Commonitem_Vehicle[pData->tid].EFF_VALUE;
//		pData->effPos		= stItem_Common_Commonitem_Vehicle[pData->tid].EFF_POS;
//		return;
//	case CLASS_ITEM_TABLE_BATTLE_PET :
//		pData->effType	= stItem_Common_Commonitem_Pet[pData->tid].EFFECT;
//		pData->effValue	= stItem_Common_Commonitem_Pet[pData->tid].EFF_VALUE;
//		pData->effPos		= stItem_Common_Commonitem_Pet[pData->tid].EFF_POS;
//		return;
//	}
//
//	// for class type item
//	if (pData->classType == CLASS_TYPE_SLASHER)
//	{
//		switch (pData->sheetType)
//		{
//		case CLASS_ITEM_TABLE_WEAPONE:
//			pData->effType 	= stItem_Class1_Weapon01[pData->tid].EFFECT;
//			pData->effValue 	= stItem_Class1_Weapon01[pData->tid].EFF_VALUE;
//			pData->effPos 	= stItem_Class1_Weapon01[pData->tid].EFF_POS;
//			return;
//		case CLASS_ITEM_TABLE_HELMET:
//			pData->effType 	= stItem_Class1_Helmet01[pData->tid].EFFECT;
//			pData->effValue 	= stItem_Class1_Helmet01[pData->tid].EFF_VALUE;
//			pData->effPos 	= stItem_Class1_Helmet01[pData->tid].EFF_POS;
//			return;
//		case CLASS_ITEM_TABLE_ARMOR:
//			pData->effType 	= stItem_Class1_Armor01[pData->tid].EFFECT;
//			pData->effValue 	= stItem_Class1_Armor01[pData->tid].EFF_VALUE;
//			pData->effPos 	= stItem_Class1_Armor01[pData->tid].EFF_POS;
//			return;
//		case CLASS_ITEM_TABLE_GLOVES:
//			pData->effType 	= stItem_Class1_Gloves01[pData->tid].EFFECT;
//			pData->effValue 	= stItem_Class1_Gloves01[pData->tid].EFF_VALUE;
//			pData->effPos 	= stItem_Class1_Gloves01[pData->tid].EFF_POS;
//			return;
//		case CLASS_ITEM_TABLE_SHOES:
//			pData->effType 	= stItem_Class1_Shoes01[pData->tid].EFFECT;
//			pData->effValue 	= stItem_Class1_Shoes01[pData->tid].EFF_VALUE;
//			pData->effPos 	= stItem_Class1_Shoes01[pData->tid].EFF_POS;
//			return;
//		case CLASS_ITEM_TABLE_AVATAR :
//			pData->effType	= stItem_Class1_Avatar01[pData->tid].EFFECT;
//			pData->effValue	= stItem_Class1_Avatar01[pData->tid].EFF_VALUE;
//			pData->effPos		= stItem_Class1_Avatar01[pData->tid].EFF_POS;
//			return;
//		}
//	}
//	else if (pData->classType == CLASS_TYPE_RANGER)
//	{
//	   switch (pData->sheetType)
//		{
//		case CLASS_ITEM_TABLE_WEAPONE:
//			pData->effType    = stItem_Class2_Weapon02[pData->tid].EFFECT;
//			pData->effValue   = stItem_Class2_Weapon02[pData->tid].EFF_VALUE;
//			pData->effPos     = stItem_Class2_Weapon02[pData->tid].EFF_POS;
//			return;
//		case CLASS_ITEM_TABLE_HELMET:
//			pData->effType    = stItem_Class2_Helmet02[pData->tid].EFFECT;
//			pData->effValue   = stItem_Class2_Helmet02[pData->tid].EFF_VALUE;
//			pData->effPos     = stItem_Class2_Helmet02[pData->tid].EFF_POS;
//			return;
//		case CLASS_ITEM_TABLE_ARMOR:
//			pData->effType    = stItem_Class2_Armor02[pData->tid].EFFECT;
//			pData->effValue   = stItem_Class2_Armor02[pData->tid].EFF_VALUE;
//			pData->effPos     = stItem_Class2_Armor02[pData->tid].EFF_POS;
//			return;
//		case CLASS_ITEM_TABLE_GLOVES:
//			pData->effType    = stItem_Class2_Gloves02[pData->tid].EFFECT;
//			pData->effValue   = stItem_Class2_Gloves02[pData->tid].EFF_VALUE;
//			pData->effPos     = stItem_Class2_Gloves02[pData->tid].EFF_POS;
//			return;
//		case CLASS_ITEM_TABLE_SHOES:
//			pData->effType    = stItem_Class2_Shoes02[pData->tid].EFFECT;
//			pData->effValue   = stItem_Class2_Shoes02[pData->tid].EFF_VALUE;
//			pData->effPos     = stItem_Class2_Shoes02[pData->tid].EFF_POS;
//			return;
//		case CLASS_ITEM_TABLE_AVATAR :
//			pData->effType	= stItem_Class2_Avatar02[pData->tid].EFFECT;
//			pData->effValue	= stItem_Class2_Avatar02[pData->tid].EFF_VALUE;
//			pData->effPos		= stItem_Class2_Avatar02[pData->tid].EFF_POS;
//			return;
//		}
//	}
//	else if (pData->classType == CLASS_TYPE_FIGHTER)
//	{
//		switch (pData->sheetType)
//		{
//		case CLASS_ITEM_TABLE_WEAPONE:
//		    pData->effType    = stItem_Class3_Weapon03[pData->tid].EFFECT;
//		    pData->effValue   = stItem_Class3_Weapon03[pData->tid].EFF_VALUE;
//		    pData->effPos     = stItem_Class3_Weapon03[pData->tid].EFF_POS;
//		    return;
//		case CLASS_ITEM_TABLE_HELMET:
//		    pData->effType    = stItem_Class3_Helmet03[pData->tid].EFFECT;
//		    pData->effValue   = stItem_Class3_Helmet03[pData->tid].EFF_VALUE;
//		    pData->effPos     = stItem_Class3_Helmet03[pData->tid].EFF_POS;
//		    return;
//		case CLASS_ITEM_TABLE_ARMOR:
//		    pData->effType    = stItem_Class3_Armor03[pData->tid].EFFECT;
//		    pData->effValue   = stItem_Class3_Armor03[pData->tid].EFF_VALUE;
//		    pData->effPos     = stItem_Class3_Armor03[pData->tid].EFF_POS;
//		    return;
//		case CLASS_ITEM_TABLE_GLOVES:
//		    pData->effType    = stItem_Class3_Gloves03[pData->tid].EFFECT;
//		    pData->effValue   = stItem_Class3_Gloves03[pData->tid].EFF_VALUE;
//		    pData->effPos     = stItem_Class3_Gloves03[pData->tid].EFF_POS;
//		    return;
//		case CLASS_ITEM_TABLE_SHOES:
//		    pData->effType    = stItem_Class3_Shoes03[pData->tid].EFFECT;
//		    pData->effValue   = stItem_Class3_Shoes03[pData->tid].EFF_VALUE;
//		    pData->effPos     = stItem_Class3_Shoes03[pData->tid].EFF_POS;
//		    return;
//		case CLASS_ITEM_TABLE_AVATAR :
//			pData->effType	= stItem_Class3_Avatar03[pData->tid].EFFECT;
//			pData->effValue	= stItem_Class3_Avatar03[pData->tid].EFF_VALUE;
//			pData->effPos		= stItem_Class3_Avatar03[pData->tid].EFF_POS;
//			return;
//		}
//	}
//	else if (pData->classType == CLASS_TYPE_MAGICIAN)
//	{
//		switch (pData->sheetType)
//		{
//		case CLASS_ITEM_TABLE_WEAPONE:
//		    pData->effType    = stItem_Class4_Weapon04[pData->tid].EFFECT;
//		    pData->effValue   = stItem_Class4_Weapon04[pData->tid].EFF_VALUE;
//		    pData->effPos     = stItem_Class4_Weapon04[pData->tid].EFF_POS;
//		    return;
//		case CLASS_ITEM_TABLE_HELMET:
//		    pData->effType    = stItem_Class4_Helmet04[pData->tid].EFFECT;
//		    pData->effValue   = stItem_Class4_Helmet04[pData->tid].EFF_VALUE;
//		    pData->effPos     = stItem_Class4_Helmet04[pData->tid].EFF_POS;
//		    return;
//		case CLASS_ITEM_TABLE_ARMOR:
//		    pData->effType    = stItem_Class4_Armor04[pData->tid].EFFECT;
//		    pData->effValue   = stItem_Class4_Armor04[pData->tid].EFF_VALUE;
//		    pData->effPos     = stItem_Class4_Armor04[pData->tid].EFF_POS;
//		    return;
//		case CLASS_ITEM_TABLE_GLOVES:
//		    pData->effType    = stItem_Class4_Gloves04[pData->tid].EFFECT;
//		    pData->effValue   = stItem_Class4_Gloves04[pData->tid].EFF_VALUE;
//		    pData->effPos     = stItem_Class4_Gloves04[pData->tid].EFF_POS;
//		    return;
//		case CLASS_ITEM_TABLE_SHOES:
//		    pData->effType    = stItem_Class4_Shoes04[pData->tid].EFFECT;
//		    pData->effValue   = stItem_Class4_Shoes04[pData->tid].EFF_VALUE;
//		    pData->effPos     = stItem_Class4_Shoes04[pData->tid].EFF_POS;
//		    return;
//		case CLASS_ITEM_TABLE_AVATAR :
//			pData->effType	= stItem_Class4_Avatar04[pData->tid].EFFECT;
//			pData->effValue	= stItem_Class4_Avatar04[pData->tid].EFF_VALUE;
//			pData->effPos		= stItem_Class4_Avatar04[pData->tid].EFF_POS;
//			return;
//		}
//	}
//	else if (pData->classType == CLASS_TYPE_ASSASSIN)
//	{
//		switch (pData->sheetType)
//		{
//		case CLASS_ITEM_TABLE_WEAPONE:
//		    pData->effType    = stItem_Class5_Weapon05[pData->tid].EFFECT;
//		    pData->effValue   = stItem_Class5_Weapon05[pData->tid].EFF_VALUE;
//		    pData->effPos     = stItem_Class5_Weapon05[pData->tid].EFF_POS;
//		    return;
//		case CLASS_ITEM_TABLE_HELMET:
//		    pData->effType    = stItem_Class5_Helmet05[pData->tid].EFFECT;
//		    pData->effValue   = stItem_Class5_Helmet05[pData->tid].EFF_VALUE;
//		    pData->effPos     = stItem_Class5_Helmet05[pData->tid].EFF_POS;
//		    return;
//		case CLASS_ITEM_TABLE_ARMOR:
//		    pData->effType    = stItem_Class5_Armor05[pData->tid].EFFECT;
//		    pData->effValue   = stItem_Class5_Armor05[pData->tid].EFF_VALUE;
//		    pData->effPos     = stItem_Class5_Armor05[pData->tid].EFF_POS;
//		    return;
//		case CLASS_ITEM_TABLE_GLOVES:
//		    pData->effType    = stItem_Class5_Gloves05[pData->tid].EFFECT;
//		    pData->effValue   = stItem_Class5_Gloves05[pData->tid].EFF_VALUE;
//		    pData->effPos     = stItem_Class5_Gloves05[pData->tid].EFF_POS;
//		    return;
//		case CLASS_ITEM_TABLE_SHOES:
//		    pData->effType    = stItem_Class5_Shoes05[pData->tid].EFFECT;
//		    pData->effValue   = stItem_Class5_Shoes05[pData->tid].EFF_VALUE;
//		    pData->effPos     = stItem_Class5_Shoes05[pData->tid].EFF_POS;
//		    return;
//		case CLASS_ITEM_TABLE_AVATAR :
//			pData->effType	= stItem_Class5_Avatar05[pData->tid].EFFECT;
//			pData->effValue	= stItem_Class5_Avatar05[pData->tid].EFF_VALUE;
//			pData->effPos		= stItem_Class5_Avatar05[pData->tid].EFF_POS;
//			return;
//		}
//	}

//	pData->effType	= -1;
//	pData->effValue	= 0;
//	pData->effPos		= -1;
}


int
ItemResource::getRandBetween(int minVal, int maxVal)
{
	if (maxVal < minVal)
	{
		maxVal = minVal;
	}

	return (rand() % (maxVal - minVal + 1)) + minVal;
}

ItemResource::ITEMRESOURCETREE &
ItemResource::GetItemResourceTree(EnumClassItemTableType eClassItemTableType)
{
	return _clsItemResourceTreeVector[eClassItemTableType];
}

ItemResource::Flyweight *
ItemResource::getFly(int sub_type, int tid, int class_type)
{
	ITEMRESOURCETREE & tree = _clsItemResourceTreeVector[sub_type];
	Flyweight * pFly = NULL;
	if (sub_type >= CLASS_ITEM_TABLE_MAX)
	{
		Key clsKey(tid, -1);
		auto itr = tree.find(clsKey);
		if (itr == tree.end())
		{
			DEBUGLOG("%s : pFly is NULL!", __FUNCTION__);
		}
		else
		{
			pFly = itr->second;
		}
	}
	else
	{
		Key clsKey(tid, class_type);
		auto itr = tree.find(clsKey);
		if (itr == tree.end())
		{
			DEBUGLOG("%s : pFly is NULL!", __FUNCTION__);
		}
		else
		{
			pFly = itr->second;
		}
	}

	return pFly;
}

} /*NResource*/ } /* namespace ProjectZ */
